Cygwin中的AWS CLI-如何清理Windows和Cygwin样式路径中的差异 [英] aws cli in cygwin - how to clean up differences in windows and cygwin style paths

查看:130
本文介绍了Cygwin中的AWS CLI-如何清理Windows和Cygwin样式路径中的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑这是我无法正确设置路径变量,但是我很茫然.

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

我已经在cygwin中使用pip安装了aws cli.

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

pip install awscli

我有两个python环境...一个Windows anaconda发行版,可以为您安装cygwin版本.

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

当我尝试运行aws cli

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'

我尝试将aws的路径添加到我的Windows路径变量中.没有运气.

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

我尝试将其添加到我的.bashrc

I've tried adding this to my .bashrc

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

没有运气.

我尝试修改python试图运行的"aws".首先,我修改了#!指向cygwin python而不是Windows python.

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

然后它可以找到要运行的文件"aws" ...但找不到要导入的任何文件..."awscli.clidriver","botocore._"等.

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

我尝试修改路径变量以指向这些位置... anaconda/Lib/site-packages ...我什至尝试在"aws"文件中执行sys.path.insert(1,path)本身....它解决了该问题,但是它加载的每个文件都在其他地方查找,而没有找到它们,而且aws .py文件中的所有内容一次都无法处理.

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.

这是cygwin中的作品...

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

将aws cli安装在cygwin python目录中,而不是在Windows anaconda环境中安装

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

不幸的是,尝试删除awscli时pip卸载挂起,而且我什至无法卸载/重新安装,我也不知道如何强迫它使用cygwin python.在尝试修复路径变量后,我很茫然.

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.

任何建议表示赞赏.

推荐答案

在上面的评论中感谢matzeri,使我得以修正.

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

问题是cygwin有它自己的python版本...但没有pip ...,所以当我在cygwin中使用"pip install"安装awscli时,它是Windows/anaconda pip.正如matzeri所指出的,该解决方案不涉及固定路径,它永远无法解决路径问题……就是这两行……

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

这篇关于Cygwin中的AWS CLI-如何清理Windows和Cygwin样式路径中的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆