Python pip 错误:“无法获取索引基 URL https://pypi.python.org/simple/”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15501133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python pip error: "Cannot fetch index base URL https://pypi.python.org/simple/"
提问by lizarisk
I'm trying to install several packages using pip. When I do this using sudo, this error occurs: "Cannot fetch index base URL https://pypi.python.org/simple/". When I execute the command without sudo, the package downloads successfully, but I don't have enough permissions. What could be the reason for such different behaviour? I'm sitting behind a proxy.
我正在尝试使用 pip 安装多个软件包。当我使用 sudo 执行此操作时,会发生此错误:“无法获取索引基 URL https://pypi.python.org/simple/”。当我在没有 sudo 的情况下执行命令时,包下载成功,但我没有足够的权限。这种不同行为的原因可能是什么?我坐在代理后面。
采纳答案by djc
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.
回答by Aaron Lelevier
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. If you look in the PIP log in Mac OS X at: /Users/username/.pip/pip.logit will give you more detail.
这是一个与 PIP 和 Python 的 PYPI 信任 SSL 证书相关的问题。如果您查看 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-packagesin Python whether it is in a virtualenvor in your normal site-packages, and get rid of the current PIP version. For me I had pip==1.5.4
在尝试不同的东西数小时后,我让 PIP 备份和运行的解决方法是在 Python 中进入我的站点包,无论它是在virtualenv 中还是在您的普通站点包中,并摆脱当前的 PIP 版本。对我来说,我有pip==1.5.4
I deleted the PIP directory and the PIP egg file. Then I ran
我删除了 PIP 目录和 PIP egg 文件。然后我跑了
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.txtwithin my virtualenv to set up all packages that I wanted that were listed in my requirements.txtfile.
这个版本的 PIP 没有 SSL 问题,然后我能够pip install -r requirements.txt在我的 virtualenv 中运行我的正常程序来设置我想要的所有包,这些包在我的requirements.txt文件中列出。
This is also the recommended hack to get passed the issue by several people on this Google Group that I found:
这也是我发现的这个 Google Group 上的几个人通过这个问题的推荐 hack:
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. 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,则每次创建新的 virtualenv 时,它都会安装该版本的 PIP,因此除非您更改全局安装的版本,否则每次都必须为每个新 PIP 执行此操作。我在开始一个新项目时遇到了这个问题,不得不再次进行修复并恢复到pip==1.2.1
回答by erbaker
回答by Viv
If you want to install any packages using pip then it is better to follow below syntax:
如果您想使用 pip 安装任何软件包,那么最好遵循以下语法:
sudo pip --proxy=http://username:password@proxyURL:portNumber install yolk
回答by ye Gucheng
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.
在文件中。
回答by Rituraj Rautela
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.
如果出现问题,请检查您的系统数据/时间,如果这不是问题,请继续执行其他建议。

