Python pip 无法安装任何东西

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17416938/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 08:09:00  来源:igfitidea点击:

pip cannot install anything

pythonpip

提问by daydreamer

> pip install yolk
Downloading/unpacking yolk
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement yolk
No distributions at all found for yolk
Storing complete log in /Users/harith/.pip/pip.log

when I read the file I see

当我阅读文件时,我看到

> cat /Users/harith/.pip/pip.log
------------------------------------------------------------
/Users/harith/.shared/virtualenvs/pennytracker/bin/pip run on Mon Jul  1 20:26:02 2013
Downloading/unpacking yolk

  Getting page https://pypi.python.org/simple/yolk/
  Could not fetch URL https://pypi.python.org/simple/yolk/: HTTP Error 503: Service Unavailable
  Will skip URL https://pypi.python.org/simple/yolk/ when looking for download links for yolk
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: HTTP Error 503: Service Unavailable
  Will skip URL https://pypi.python.org/simple/ when looking for download links for yolk
  Cannot fetch index base URL https://pypi.python.org/simple/

  URLs to search for versions for yolk:
  * https://pypi.python.org/simple/yolk/
  Getting page https://pypi.python.org/simple/yolk/
  Could not fetch URL https://pypi.python.org/simple/yolk/: HTTP Error 503: Service Unavailable
  Will skip URL https://pypi.python.org/simple/yolk/ when looking for download links for yolk
  Could not find any downloads that satisfy the requirement yolk

No distributions at all found for yolk

    Exception information:
    Traceback (most recent call last):
      File "/Users/harith/.shared/virtualenvs/pennytracker/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main
        status = self.run(options, args)
      File "/Users/harith/.shared/virtualenvs/pennytracker/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 266, in run
        requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
      File "/Users/harith/.shared/virtualenvs/pennytracker/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1026, in prepare_files
        url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
      File "/Users/harith/.shared/virtualenvs/pennytracker/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 171, in find_requirement
        raise DistributionNotFound('No distributions at all found for %s' % req)
    DistributionNotFound: No distributions at all found for yolk

Am i doing anything wrong?

我做错了什么吗?

采纳答案by paulwithap

This is the full text of the blog post linked below:

这是下面链接的博客文章的全文:

If you've tried installing a package with pip recently, you may have encountered this error:

如果您最近尝试使用 pip 安装软件包,您可能会遇到此错误:

Could not fetch URL https://pypi.python.org/simple/Django/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/Django/ when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Could not fetch URL https://pypi.python.org/simple/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/ when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/Django/1.5.1: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/Django/1.5.1 when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Could not fetch URL https://pypi.python.org/simple/Django/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/Django/ when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Could not find any downloads that satisfy the requirement Django==1.5.1 (from -r requirements.txt (line 1))
No distributions at all found for Django==1.5.1 (from -r requirements.txt (line 1))
Storing complete log in /Users/paul/.pip/pip.log

This seems to be an issue with an old version of OpenSSL being incompatible with pip 1.3.1. If you're using a non-stock Python distribution (notably EPD 7.3), you're very likely to have a setup that isn't going to work with pip 1.3.1 without a shitload of work.

这似乎是旧版本的 OpenSSL 与 pip 1.3.1 不兼容的问题。如果您使用的是非库存 Python 发行版(特别是 EPD 7.3),那么您的设置很可能在没有大量工作的情况下无法与 pip 1.3.1 一起使用。

The easy workaround for now, is to install pip 1.2.1, which does not require SSL:

目前最简单的解决方法是安装不需要 SSL 的 pip 1.2.1:

curl -O https://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz
tar xvfz pip-1.2.1.tar.gz
cd pip-1.2.1
python setup.py install

If you are using EPD, and you're not using it for a class where things might break, you may want to consider installing the new incarnation: Enthought Canopy. I know they were aware of the issues caused by the previous version of OpenSSL, and would imagine they are using a new version now that should play nicely with pip 1.3.1.

如果您正在使用 EPD,并且您没有将它用于可能会出现问题的课程,您可能需要考虑安装新的化身:Enthought Canopy。我知道他们知道由以前版本的 OpenSSL 引起的问题,并且可以想象他们现在使用的新版本应该可以很好地与 pip 1.3.1 配合使用。

回答by janos

The explanation is in your logs:

解释在您的日志中:

Could not fetch URL https://pypi.python.org/simple/yolk/: HTTP Error 503: Service Unavailable

Notice the HTTP Error 503: Service Unavailable. It seems the site was down when you were trying to do this.

请注意HTTP Error 503: Service Unavailable. 当您尝试执行此操作时,该站点似乎已关闭。

It's good to know that HTTP 5xx errors are server side errors, so you can know the problem was not in your local network but in the remote network.

很高兴知道 HTTP 5xx 错误是服务器端错误,因此您可以知道问题不在本地网络中,而是在远程网络中。

It means try again later ;-) (and cross fingers...) (It works for me now btw.)

这意味着稍后再试;-)(和交叉手指......)(顺便说一句,它现在对我有用。)

回答by Burhan Khalid

pip has mirror support

pip 有镜像支持

pip --use-mirrors install yolk

As of version 1.5, this option will be removed:

从 1.5 版开始,此选项将被删除

1.5 (unreleased)

BACKWARD INCOMPATIBLE pip no longer supports the --use-mirrors, -M, and --mirrors flags. The mirroring support has been removed. In order to use a mirror specify it as the primary index with -i or --index-url, or as an additional index with --extra-index-url. (Pull #1098, CVE-2013-5123)

BACKWARD INCOMPATIBLE pip no longer will scrape insecure external urls by default nor will it install externally hosted files by default. Users may opt into installing externally hosted or insecure files or urls using --allow-external PROJECT and --allow-insecure PROJECT. (Pull #1055)

Added colors to the logging output in order to draw attention to important warnings and errors. (Pull #1109)

Added warnings when using an insecure index, find-link, or dependency link. (Pull #1121)

1.5(未发布)

向后不兼容的 pip 不再支持 --use-mirrors、-M 和 --mirrors 标志。镜像支持已被删除。为了使用镜像,使用 -i 或 --index-url 将其指定为主索引,或者使用 --extra-index-url 将其指定为附加索引。(拉取 #1098,CVE-2013-5123)

向后不兼容的 pip 不再默认抓取不安全的外部 url,也不会默认安装外部托管的文件。用户可以选择使用 --allow-external PROJECT 和 --allow-insecure PROJECT 安装外部托管或不安全的文件或 URL。(拉#1055)

为日志输出添加了颜色,以引起对重要警告和错误的注意。(拉#1109)

添加了使用不安全索引、查找链接或依赖项链接时的警告。(拉#1121)

回答by xinoman12

It's because in the pip configuration the index-url parameter should point to the new pypi url. Change the file in ~/.pip/pip.confor if you are running pip as root, in: /root/.pip/pip.conf.

这是因为在 pip 配置中 index-url 参数应该指向新的 pypi url。更改文件 in~/.pip/pip.conf或者如果您以 root 身份运行 pip,请在:/root/.pip/pip.conf

Probably you have this:

可能你有这个:

 [global]
 index-url=http://f.pypi.python.org/simple

You shoudl change it for this:

你应该为此改变它:

  [global]
  index-url=https://pypi.python.org/pypi/

And then all should work as before. I hope it helps you.

然后一切都应该像以前一样工作。我希望它能帮助你。

回答by Marios V

I had a similar problem with pip and easy_install:

我对 pip 和 easy_install 有类似的问题:

Cannot fetch index base URL https://pypi.python.org/simple/

Cannot fetch index base URL https://pypi.python.org/simple/

As suggested in the referenced blog post, there must be an issue with some older versions of OpenSSL being incompatible with pip 1.3.1.

正如引用的博客文章中所建议的那样,某些旧版本的 OpenSSL与 pip 1.3.1 不兼容肯定存在问题。

Installing pip-1.2.1 is a working workaround.

安装 pip-1.2.1 是一种可行的解决方法。

Possibly related question.

可能相关的问题

[Edit]:

[编辑]:

This definitely happens in RHEL/CentOS 4 distros

这肯定会发生在 RHEL/CentOS 4 发行版中

回答by lapin

I used to use the easy_install pip==1.2.1workaround but I randomly foundthat if you're having this bug, you probably installed a 32bit version of python on a 64bit machine.

我曾经使用该easy_install pip==1.2.1解决方法,但我随机发现如果您遇到此错误,则您可能在 64 位机器上安装了 32 位版本的 python。

In short : If you install a 64bit version of it by installing it from the source and then build your virtualenv upon it, you wont have that pip bug anymore.

简而言之:如果您通过从源代码安装它来安装它的 64 位版本,然后在其上构建您的 virtualenv,您将不再有那个 pip 错误。

回答by jspy

This problem is most-likely caused by DNS setup: server cannot resolve the Domain Name, so cannot download the package.

这个问题很可能是由DNS设置引起的:服务器无法解析域名,因此无法下载包。

Solution:

解决方案:

     sudo nano /etc/network/interface

add a line: dns-nameservers 8.8.8.8

添加一行:dns-nameservers 8.8.8.8

save file and exit

保存文件并退出

     sudo ifdown eth0 && sudo ifup eth0

Then pip install should be working now.

然后 pip install 现在应该可以工作了。

回答by Chetan

Your system clock is likely set in the past.Check the time using the date command and set it right

您的系统时钟可能设置在过去。使用 date 命令检查时间并设置正确

回答by GusC

I had the same issue with pip 1.5.6.

我对 pip 1.5.6 有同样的问题。

I just deleted the ~/.pip folder and it worked like a charm.

我刚刚删除了 ~/.pip 文件夹,它就像一个魅力。

rm -r ~/.pip/

回答by geographika

I had this error message occur as I had set a Windows Environment Variable to an invalid certificate file.

由于我将 Windows 环境变量设置为无效的证书文件,因此出现此错误消息。

Check if you have a CURL_CA_BUNDLEvariable by typing SETat the command prompt.

CURL_CA_BUNDLE通过SET在命令提示符下键入来检查您是否有变量。

You can override it for the current session with SET CURL_CA_BUNDLE=

您可以为当前会话覆盖它 SET CURL_CA_BUNDLE=

The pip.log contained the following:

pip.log 包含以下内容:

Getting page https://pypi.python.org/simple/pip/
Could not fetch URL https://pypi.python.org/simple/pip/: connection error: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib