[英]Python pip error: “Cannot fetch index base URL https://pypi.python.org/simple/”
I'm trying to install several packages using pip. 我正在尝试使用pip安装几个软件包。 When I do this using sudo, this error occurs: "Cannot fetch index base URL https://pypi.python.org/simple/ ".
当我使用sudo执行此操作时,会出现此错误:“无法获取索引基本URL https://pypi.python.org/simple/ ”。 When I execute the command without sudo, the package downloads successfully, but I don't have enough permissions.
当我执行不带sudo的命令时,包下载成功,但我没有足够的权限。 What could be the reason for such different behaviour?
这种不同行为可能是什么原因? I'm sitting behind a proxy.
我坐在代理人后面。
Maybe try with sudo -E
: 也许尝试使用
sudo -E
:
-E The -E (preserve environment) option indicates to the secu‐
rity policy that the user wishes to preserve their existing
environment variables. The security policy may return an
error if the -E option is specified and the user does not
have permission to preserve the environment.
On the assumption that your proxy settings are set in your normal user environment, but not the one you get when you run sudo
. 假设您的代理设置是在普通用户环境中设置的,而不是您在运行
sudo
时获得的设置。
I got this issue when trying to use pip==1.5.4
我在尝试使用
pip==1.5.4
时遇到了这个问题
This is an issue related to PIP and Python's PYPI trusting SSL certificates. 这是与PIP和Python的PYPI信任SSL证书相关的问题。 If you look in the PIP log in Mac OS X at: /Users/username/.pip/pip.log it will give you more detail.
如果您查看Mac OS X中的PIP日志: /Users/username/.pip/pip.log ,它将为您提供更多详细信息。
My workaround to get PIP back up and running after hours of trying different stuff was to go into my site-packages in Python whether it is in a virtualenv or in your normal site-packages , and get rid of the current PIP version. 我的解决方法是在经过几个小时尝试不同的东西之后让PIP重新启动并运行,无论是在virtualenv中还是在普通的站点包中 ,都可以使用Python进入我的站点 包 ,并摆脱当前的PIP版本。 For me I had
pip==1.5.4
对我来说,我
pip==1.5.4
I deleted the PIP directory and the PIP egg file. 我删除了PIP目录和PIP egg文件。 Then I ran
然后我跑了
easy_install pip==1.2.1
This version of PIP doesn't have the SSL issue, and then I was able to go and run my normal pip install -r requirements.txt
within my virtualenv to set up all packages that I wanted that were listed in my requirements.txt
file. 这个版本的PIP没有SSL问题,然后我就可以在我的virtualenv中运行我的普通
pip install -r requirements.txt
来设置我想要的所有包在requirements.txt
文件中列出的包。
This is also the recommended hack to get passed the issue by several people on this Google Group that I found: 这也是我发现这个谷歌集团的几个人通过该问题的推荐黑客:
https://groups.google.com/forum/#!topic/beagleboard/aSlPCNYcVjw https://groups.google.com/forum/#!topic/beagleboard/aSlPCNYcVjw
[edit] [编辑]
If you have a different version of PIP installed globally, every time you create a new virtualenv it will install that version of PIP, so you will have to do this each time for each new PIP unless you change the globally installed version. 如果您在全局安装了不同版本的PIP,则每次创建新的virtualenv时都会安装该版本的PIP,因此除非您更改全局安装的版本,否则每次为每个新PIP都必须执行此操作。 I ran into this issue when starting a new project, and had to do the fix again and revert back to
pip==1.2.1
我在启动一个新项目时遇到了这个问题,并且不得不再次进行修复并恢复到
pip==1.2.1
如果你想使用pip安装任何软件包,那么最好遵循以下语法:
sudo pip --proxy=http://username:password@proxyURL:portNumber install yolk
I have encountered this problem and found the answer finally solved. 我遇到了这个问题,发现答案终于解决了。
You can try to add a new file /root/.pip/pip.conf
, then write: 你可以尝试添加一个新文件
/root/.pip/pip.conf
,然后写:
[global]
index-url=http://pypi.douban.com/simple/
in the file. 在文件中。
My solution was different for this problem. 我的解决方案与此问题不同。
My system's Date and Time were not synchronized. 我的系统的日期和时间未同步。
If the problem appears check your system data/time if that's not the problem proceed with the another suggestions. 如果问题出现,请检查您的系统数据/时间,如果不是问题,请继续进行其他建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.