简体   繁体   English

Python pip错误:“无法获取索引基URL https://pypi.python.org/simple/”

[英]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

From the pip docs , if you are installing behind a proxy: pip文档中 ,如果要在代理后面安装:

python get-pip.py --proxy="[user:passwd@]proxy.server:port" python get-pip.py --proxy =“[user:passwd @] proxy.server:port”

如果你想使用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.

相关问题 pip 连接失败:无法获取索引基 URL http://pypi.python.org/simple/ - pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/ 无法获取索引库 URL https://pypi.python.org/simple/ ~ 安装后 Python 3 OS X - Cannot fetch index base URL https://pypi.python.org/simple/ ~ After Installing Python 3 OS X 无法安装Django-无法获取索引基本URL https://pypi.python.org/simple/ - Can't install Django - Cannot fetch index base URL https://pypi.python.org/simple/ 我无法升级pip:无法获取URL https://pypi.python.org/simple/pip/:存在一个确认ssl证书的问题 - I can't upgrade pip: Could not fetch URL https://pypi.python.org/simple/pip/: There was a prόblem confirming the ssl certificate curl https://pypi.python.org/simple/pip不返回任何内容 - curl https://pypi.python.org/simple/pip returns nothing 配置pip以从pypi.python.org获取丢失的软件包 - configure pip to get missing package from pypi.python.org python pip安装错误'无法获取基本索引URL' - python pip installation error 'cannot fetch base index URL' 为什么pypi.python.org/simple上有一些软件包,但是没有页面? - Why are some packages on pypi.python.org/simple, but have no page? 无法安装分发:pypi.python.org 拒绝 http - Cannot install distribute: pypi.python.org rejecting http 与pypi.python.org的连接超时 - Connection to pypi.python.org timed out
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM