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

我只是一个虾纸丫 提交于 2019-12-03 03:18:11

When running pip install awscli from cygwin, it may install awscli in Window's Anaconda Python installation, instead of in Cygwin's Python (which is what you want). Then, when running aws, you will get an error that the aws executable can't be found. The solution I found was installing python/pip inside cygwin by following below bash commands from cygwin shell:

pip uninstall awscli
wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
apt-cyg install python
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install awscli

Make sure you have wget installed in cygwin.

Ryan Chase

After a LOT of time spent on this, I found a solution that works.

The primary issue is that the cygwin didn't come with python installed, and doesn't know where to find the existing Windows Anaconda version on your machine. This can be verified by running which python from within cygwin - it couldn't find where python is saved. Note that this can be confusing because running pip install awscli likely doesn't throw an error message. Cygwin actually installs awscli in the Window's Anaconda installation of Python (I find this odd since we didn't run conda install awscli).

HOWEVER, rather than try to point cygwin to the already installed version of Anaconda python on your machine it will save you a ton of headache to just install a cygwin-specific instance of python. The steps to do so are documented here: http://wiki.fast.ai/index.php/Awscli_in_cygwin

  1. pip uninstall awscli
  2. wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
  3. install apt-cyg /bin
  4. apt-cyg install python
  5. wget https://bootstrap.pypa.io/get-pip.py
  6. python get-pip.py
  7. pip install awscli

...Note, however, that the first command pip uninstall awscli "hung up" for me. So just escape out of it using quit() and continue with the others in order.

You can check that everything worked if you run which python in cygwin and it points to the cygin version (i.e. /usr/bin/python , as opposed to: /users/.../Anaconda2/).

Additionally, if you happen to be asking this in conjunction with watching the setup video for the fast.ai course (http://course.fast.ai/lessons/aws.html), then the next step is CRITICAL for Windows users: when you download all the shell scripts from Github setup folder (https://github.com/fastai/courses/tree/master/setup), Windows automatically adds CRLF line terminators! Therefore, in cygwin, run the following commands to remove these line endings:

  1. apt-cyg install dos2unix
  2. dos2unix setup_p2.sh
  3. dos2unix setup_instance.sh
  4. then finally, bash setup_p2.sh

This should do the trick.

Adding my fix, for people who are facing this issue in Anacond2

After you install anaconda2 , run this command in cygwin (suppose you have installed it at c:\anaconda2)

echo "PATH=\$PATH:/cygdrive/c/anaconda2" >> .bash_profile
echo "PATH=\$PATH:/cygdrive/c/anaconda2/Scripts" >> .bash_profile
source .bash_profile 

More info available at https://www.davidbaumgold.com/tutorials/set-up-python-windows/#installing-cygwin

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!