Search code examples
pythoncygwinaws-cli

aws cli in cygwin - how to clean up differences in windows and cygwin style paths


I suspect this is my ineptitude in getting path variables set right, but I'm at a loss.

I've installed the aws cli using pip in cygwin.

pip install awscli

I have two python environments... a windows anaconda distribution, and the version cygwin can install for you.

which python 
> /usr/bin/python

where python
> C:\cygwin64\bin\python
> C:\windows-style-path-to-anaconda\python.exe

when I try to run aws cli

aws --version
> C:\windows-style-path-to-anaconda\python.exe: can't open file 
> 'cygdrive/c/cygdrive-style-path-to-anaconda/Scripts/aws': 
> [Errno 2] No such file or directory'

I've tried adding the path to aws to my windows path variable. No luck.

I've tried adding this to my .bashrc

export PATH="$PATH:/cygdrive/c/cygdrive-style-path-to-anaconda/Scripts"

No luck.

I've tried modifying the 'aws' that python is trying to run. First I modified the #! to point to the cygwin python instead of the windows python.

#!c:\cygwin64\bin\python

then it could find the file 'aws' to run... but it couldn't find any of the files to import... 'awscli.clidriver', 'botocore._', etc.

I tried modifying my path variables to point to the location of these... anaconda/Lib/site-packages... I even tried doing a sys.path.insert(1, path) in the 'aws' file itself.... it fixed that problem but every single file it loaded was looking in other places and not finding them, and it was too many things to mess with one at a time in the aws .py files.

here's what sort of works... in cygwin...

cd /cygdrive/c/cygwin-path-to-anaconda/Scripts
./aws --version
> aws-cli/1.10.26 Python/2.7.11 Windows/7 botocore/1.4.17

but there has to be a better way, right? either...

  • get my path variables set right

  • get the aws cli installed in the cygwin python directory instead of the windows anaconda environment

unfortunately, pip uninstall just hangs trying to remove awscli, and I don't know how to force it to use the cygwin python if I even could uninstall/reinstall. And after a bunch of tries at fixing my path variables, I'm at a loss.

Any advice appreciated.


Solution

  • Thanks to matzeri in the comments above for steering me to the fix.

    The problem was that cygwin had it's own python version... but not pip... so when I used "pip install" in cygwin to install awscli, it was the windows/anaconda pip. the solution didn't involve fixing paths, as matzeri pointed out, it would never resolve that with paths... it was these two lines...

    python -m ensurepip  # install a cygwin pip
    pip install awscli   # to install awscli for cygwin