Aws-cli: Running aws cli from git bash on windows

Created on 9 May 2015  Â·  11Comments  Â·  Source: aws/aws-cli

After following the installation via pip on WIndows 8.1 x64, I have python, pip and aws installed in C:\Program Files\Python and C:\Program Files\Python\Scripts.

Note that pip install awscli produced the following error:

Fatal error in launcher: Unable to create process using '""C:\Program Files\Pyth
on\python.exe"" "C:\Program Files\Python\Scripts\pip.exe" install awscli'

but python "C:\Program Files\Python\Scripts\pip.exe" ![image](https://cloud.githubusercontent.com/assets/2556751/7549846/fea9a17a-f640-11e4-974b-5e11497bc21b.png) install awscli did work.

I also have git installed in C:\Program Files (x86)\Git.

In order to benefit from the unix tools (cut, grep, ...) provided by Git Bash on windows, I would like to run the AWS CLI in git bash but I get the following error:

image

Note that python --version and python "C:\Program Files\Python\Scripts\pip.exe" --help both work with Git Bash.

Any chance this can be fixed?

Most helpful comment

What works for recent versions of AWS CLI:

alias aws="winpty /C/Program\ Files/Amazon/AWSCLI/bin/aws.cmd"

alias py="winpty python.exe"

All 11 comments

I have tried adding the following .bashrc file in the windows user directory

#!/bin/bash

# Make .bashrc available to non interactive shells (.sh scripts)
export BASH_ENV=~/.bashrc

# create an alias for aws
alias aws='python "C:\Program Files\Python\Scripts\aws"'

The interactive shell gets the aws alias but not the shell scripts.

Interesting. I just did the entire install process myself using a window git bash and I was able to install and run the CLI successfully. I think the only spot I deviated in was that I installed python in a new directory Python34 instead of installing it under Program Files. I did some searching and it may have to do with the directory you are using has a space in its name?

http://stackoverflow.com/questions/24627525/fatal-error-in-launcher-unable-to-create-process-using-c-program-files-x86

Let me know if this helps.

I have been using Python 2.7.9 but I suppose the space in Program Files might be the issue.
Note that the link you have sent me contains a comment from a PIP.exe team member that points to their issue management system at https://bitbucket.org/pypa/distlib/issue/47/exe-launcher-fails-if-there-is-a-space-in and this is something they have fixed within pip, so this might be something the AWS CLI team might want to fix too.

Anyway, I have found a workaround.

1) Add a ~/.bashrc file with

# create an alias for aws
alias aws='python "C:\Program Files\Python\Scripts\aws"'

2) Prefix all .sh files using the aws cli with

source ~/.bashrc

Good to hear you got this to work. Resolving issue as it looks like something pip needs to fix and is not an issue with the CLI code itself. And once it is fixed and released in pip, users just need to make sure they are installing with a version of pip that has the fix.

PIP is fixed in Python 2.7.10

I had no problem installing from pip, but i'm finding that git bash (windows 10) and aws cli don't play well together. aws configure just hangs. aws help runs, but there is a large delay. No problems on the same machine and powershell or cmd. Ideas?

I do as follows. I don't remember where I read it. Probably on SO. winpty is some utility that makes it happen.

My .bashrc file

alias aws="winpty /C/Program Files/Amazon/AWSCLI/aws.exe"

alias py="winpty python.exe"

Or you may append AWSCLI directory C:\Program Files\Amazon\AWSCLI to system PATH variable and then in .bashrc w/o full path:

alias aws="winpty aws.exe"

What works for recent versions of AWS CLI:

alias aws="winpty /C/Program\ Files/Amazon/AWSCLI/bin/aws.cmd"

alias py="winpty python.exe"

If you only have one Python, you can also change the shebang in C:\Program Files\PythonXX\Scripts\aws to be #! python instead of the full path.

Download it by following the recommended set of commands for Windows:
New-Item ‘C:Program Files\Amazon\ECSCLI’ -type directory
Invoke-WebRequest -OutFile ‘C:Program Files\Amazon\ECSCLI\ecs-cli.exe’ https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-windows-amd64-latest.exe

Copy the downloaded file from C:Program Files\Amazon\ECSCLI\ecs-cli.exe to your virtualenv's binary file location. Start playing with your ecs-cli from your python virtualenv

Was this page helpful?
0 / 5 - 0 ratings