安装几乎所有库的pip问题

问题:安装几乎所有库的pip问题

我很难用pip安装几乎所有东西。我是编码的新手,所以我认为这可能是我做错了的事情,因此选择easy_install来完成我需要完成的大部分工作,而这种工作通常是有效的。但是,现在我正在尝试下载nltk库,但都没有完成任务。

我尝试进入

sudo pip install nltk

但得到以下回应:

/Library/Frameworks/Python.framework/Versions/2.7/bin/pip run on Sat May  4 00:15:38 2013
Downloading/unpacking nltk

  Getting page https://pypi.python.org/simple/nltk/
  Could not fetch URL [need more reputation to post link]: 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 [need more reputation to post link]/simple/nltk/ when looking for download links for nltk

  Getting page [need more reputation to post link]/simple/
  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 [need more reputation to post link] when looking for download links for nltk

  Cannot fetch index base URL [need more reputation to post link]

  URLs to search for versions for nltk:
  * [need more reputation to post link]
  Getting page [need more reputation to post link]
  Could not fetch URL [need more reputation to post link]: 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 [need more reputation to post link] when looking for download links for nltk

  Could not find any downloads that satisfy the requirement nltk

No distributions at all found for nltk

Exception information:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/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 "/Library/Frameworks/Python.framework/Versions/2.7/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 "/Library/Frameworks/Python.framework/Versions/2.7/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 "/Library/Frameworks/Python.framework/Versions/2.7/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 nltk

--easy_install installed fragments of the library and the code ran into trouble very quickly upon trying to run it.

对这个问题有什么想法吗?在此期间,我非常感谢您提供一些反馈意见,以帮助我解决问题或解决问题。

I have a difficult time using pip to install almost anything. I’m new to coding, so I thought maybe this is something I’ve been doing wrong and have opted out to easy_install to get most of what I needed done, which has generally worked. However, now I’m trying to download the nltk library, and neither is getting the job done.

I tried entering

sudo pip install nltk

but got the following response:

/Library/Frameworks/Python.framework/Versions/2.7/bin/pip run on Sat May  4 00:15:38 2013
Downloading/unpacking nltk

  Getting page https://pypi.python.org/simple/nltk/
  Could not fetch URL [need more reputation to post link]: 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 [need more reputation to post link]/simple/nltk/ when looking for download links for nltk

  Getting page [need more reputation to post link]/simple/
  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 [need more reputation to post link] when looking for download links for nltk

  Cannot fetch index base URL [need more reputation to post link]

  URLs to search for versions for nltk:
  * [need more reputation to post link]
  Getting page [need more reputation to post link]
  Could not fetch URL [need more reputation to post link]: 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 [need more reputation to post link] when looking for download links for nltk

  Could not find any downloads that satisfy the requirement nltk

No distributions at all found for nltk

Exception information:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/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 "/Library/Frameworks/Python.framework/Versions/2.7/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 "/Library/Frameworks/Python.framework/Versions/2.7/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 "/Library/Frameworks/Python.framework/Versions/2.7/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 nltk

--easy_install installed fragments of the library and the code ran into trouble very quickly upon trying to run it.

Any thoughts on this issue? I’d really appreciate some feedback on how I can either get pip working or something to get around the issue in the meantime.


回答 0

我发现将pypi主机指定为受信任就足够了。例:

pip install --trusted-host pypi.python.org pytest-xdist
pip install --trusted-host pypi.python.org --upgrade pip

这解决了以下错误:

  Could not fetch URL https://pypi.python.org/simple/pytest-cov/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) - skipping
  Could not find a version that satisfies the requirement pytest-cov (from versions: )
No matching distribution found for pytest-cov

2018年4月更新:对于任何收到TLSV1_ALERT_PROTOCOL_VERSION错误的人:与OP的受信任主机/验证问题或此答案无关。而是TLSV1错误是因为您的解释器不支持TLS v1.2,所以您必须升级您的解释器。例如见https://news.ycombinator.com/item?id=13539034http://pyfound.blogspot.ca/2017/01/time-to-upgrade-your-python-tls-v12.htmlHTTPS ://bugs.python.org/issue17128

2019年2月更新:对于某些更新点子可能就足够了。如果以上错误阻止您执行此操作,请使用get-pip.py。例如在Linux上,

curl https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

有关更多详细信息,参见https://pip.pypa.io/en/stable/installing/

I found it sufficient to specify the pypi host as trusted. Example:

pip install --trusted-host pypi.python.org pytest-xdist
pip install --trusted-host pypi.python.org --upgrade pip

This solved the following error:

  Could not fetch URL https://pypi.python.org/simple/pytest-cov/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) - skipping
  Could not find a version that satisfies the requirement pytest-cov (from versions: )
No matching distribution found for pytest-cov

Update April 2018: To anyone getting the TLSV1_ALERT_PROTOCOL_VERSION error: it has nothing to do with trusted-host/verification issue of the OP or this answer. Rather the TLSV1 error is because your interpreter does not support TLS v1.2, you must upgrade your interpreter. See for example https://news.ycombinator.com/item?id=13539034, http://pyfound.blogspot.ca/2017/01/time-to-upgrade-your-python-tls-v12.html and https://bugs.python.org/issue17128.

Update Feb 2019: For some it may be sufficient to upgrade pip. If the above error prevents you from doing this, use get-pip.py. E.g. on Linux,

curl https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

More details at https://pip.pypa.io/en/stable/installing/.


回答 1

我使用的是pip版本,9.0.1并且存在相同的问题,以上所有答案都无法解决问题,并且由于其他原因,我无法通过brew安装python / pip。

升级点子即可9.0.3解决问题。而且因为我无法使用pip升级pip,所以我下载了源代码并手动进行了安装。

  1. -从下载PIP的正确版本https://pypi.org/simple/pip/
  2. sudo python3 pip-9.0.3.tar.gz -安装点子

或者您可以使用以下方法安装更新的点子:

curl https://bootstrap.pypa.io/get-pip.py | python

I used pip version 9.0.1 and had the same issue, all the answers above didn’t solve the problem, and I couldn’t install python / pip with brew for other reasons.

Upgrading pip to 9.0.3 solved the problem. And because I couldn’t upgrade pip with pip I downloaded the source and installed it manually.

  1. Download the correct version of pip from – https://pypi.org/simple/pip/
  2. sudo python3 pip-9.0.3.tar.gz – Install pip

Or you can install newer pip with:

curl https://bootstrap.pypa.io/get-pip.py | python

回答 2

Pypi删除了对小于1.2的TLS版本的支持

您需要重新安装Pip,然后执行

curl https://bootstrap.pypa.io/get-pip.py | python

或对于全局Python:

curl https://bootstrap.pypa.io/get-pip.py | sudo python

Pypi removed support for TLS versions less than 1.2

You need to re-install Pip, do

curl https://bootstrap.pypa.io/get-pip.py | python

or for global Python:

curl https://bootstrap.pypa.io/get-pip.py | sudo python

回答 3

我使用的是pip3版本9.0.1,最近无法通过命令安装任何软件包pip3 install

Mac OS版本:EI Captain 10.11.5

python版本: 3.5

我尝试了命令:

curl https://bootstrap.pypa.io/get-pip.py | python

它对我不起作用。

因此,我10.0.0通过输入以下命令卸载了较旧的pip并安装了最新版本:

python3 -m pip uninstall pip setuptools
curl https://bootstrap.pypa.io/get-pip.py | python3

现在我的问题解决了。如果您使用的是python2,则可以将python3替换为python。我希望它也对您有用。

顺便说一下,对于像我这样的新秀,您必须输入代码: sudo -i

获得根本权利:)祝你好运!

I used pip3 version 9.0.1 and was unable to install any packages recently via the commandpip3 install.

Mac os version: EI Captain 10.11.5.

python version: 3.5

I tried the command:

curl https://bootstrap.pypa.io/get-pip.py | python

It didn’t work for me.

So I uninstalled the older pip and installed the newest version10.0.0 by entering this:

python3 -m pip uninstall pip setuptools
curl https://bootstrap.pypa.io/get-pip.py | python3

Now my problem was solved. If you are using the python2, you can substitute the python3 with python. I hope it also works for you.

By the way, for some rookies like me, you have to enter the code: sudo -i

to gain the root right :) Good luck!


回答 4

您可能会看到此错误;也可以在这里看到。

最简单的解决方法是将pip降级为不使用SSL:的点easy_install pip==1.2.1。这会使您失去使用SSL的安全优势。真正的解决方案是使用链接到最新SSL库的Python发行版。

You’re probably seeing this bug; see also here.

The easiest workaround is to downgrade pip to one that doesn’t use SSL: easy_install pip==1.2.1. This loses you the security benefit of using SSL. The real solution is to use a Python distribution linked to a more recent SSL library.


回答 5

SSL错误的另一个原因可能是糟糕的系统时间–如果证书与当前时间相距太远,证书将无法验证。

Another cause of SSL errors can be a bad system time – certificates won’t validate if it’s too far off from the present.


回答 6

对我有用的唯一解决方案是:

sudo curl https://bootstrap.pypa.io/get-pip.py | 须藤python

The only solution that worked for me is:

sudo curl https://bootstrap.pypa.io/get-pip.py | sudo python


回答 7

我通过添加--trusted-host pypi.python.org选项解决了类似的问题

I solved a similar problem by adding the --trusted-host pypi.python.org option


回答 8

要安装任何其他软件包,我必须使用最新版本的pip,因为9.0.1存在此SSL问题。要通过点子本身升级点子,我必须首先解决此SSL问题。要跳出这个无尽的循环,我发现这是唯一对我有用的方法。

  1. 在此页面中找到最新版本的pip:https//pypi.org/simple/pip/
  2. 下载.whl最新版本的文件。
  3. 使用pip安装最新的pip。(在这里使用您自己的最新版本)

须藤点安装pip-10.0.1-py2.py3-none-any.whl

现在pip是最新版本,可以安装任何东西。

To install any other package I have to use the latest version of pip, since the 9.0.1 has this SSL problem. To upgrade the pip by pip itself, I have to solve this SSL problem first. To jump out of this endless loop, I find this only way that works for me.

  1. Find the latest version of pip in this page: https://pypi.org/simple/pip/
  2. Download the .whl file of the latest version.
  3. Use pip to install the latest pip. (Use your own latest version here)

sudo pip install pip-10.0.1-py2.py3-none-any.whl

Now the pip is the latest version and can install anything.


回答 9

解决方案 -通过标记以下受信任的主机来安装任何软件包

  • pypi.python.org
  • pypi.org
  • files.pythonhosted.org

临时解决方案

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}

永久解决方案 -将您的PIP(9.0.1版本的问题)更新为最新版本。

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org pytest-xdist

python -m pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade pip

Solution – Install any package by marking below hosts trusted

  • pypi.python.org
  • pypi.org
  • files.pythonhosted.org

Temporary solution

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}

Permanent solution – Update your PIP(problem with version 9.0.1) to latest.

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org pytest-xdist

python -m pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade pip

回答 10

macOS Sierra 10.12.6。无法通过pip安装任何东西(通过homebrew安装的python)。以上所有答案均无效。

最终,从python 3.5升级到3.6可行。

brew update
brew doctor #(in case you see such suggestion by brew)

然后按照brew的任何其他建议,即覆盖python的链接。

macOS Sierra 10.12.6. Wasn’t able to install anything through pip (python installed through homebrew). All the answers above didn’t work.

Eventually, upgrade from python 3.5 to 3.6 worked.

brew update
brew doctor #(in case you see such suggestion by brew)

then follow any additional suggestions by brew, i.e. overwrite link to python.


回答 11

我有同样的问题。我刚刚将python从2.7.0更新为2.7.15。它解决了这个问题。

您可以在此处下载。

I had the same problem. I just updated the python from 2.7.0 to 2.7.15. It solves the problem.

You can download here.


回答 12

正如blackjar在上面发布的,以下几行对我有用

pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx

您需要同时给出全部三个--trusted-host options。看完答案后,我只尝试了第一个,但那样对我来说并不起作用。

As posted above by blackjar, the below lines worked for me

pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx

You need to give all three --trusted-host options. I was trying with only the first one after looking at the answers but it didn’t work for me like that.


回答 13

您还可以使用conda安装软件包:请参见http://conda.pydata.org

conda install nltk

使用conda的最佳方法是下载Miniconda,但您也可以尝试

pip install conda
conda init
conda install nltk

You can also use conda to install packages: See http://conda.pydata.org

conda install nltk

The best way to use conda is to download Miniconda, but you can also try

pip install conda
conda init
conda install nltk

回答 14

对我来说,最新的pip(1.5.6)可以与不安全的nltk软件包一起使用,如果您只是告诉它不要对安全性如此挑剔的话:

pip install --upgrade --force-reinstall --allow-all-external --allow-unverified ntlk nltk

For me, the latest pip (1.5.6) works fine with the insecure nltk package if you just tell it not to be so picky about security:

pip install --upgrade --force-reinstall --allow-all-external --allow-unverified ntlk nltk

回答 15

试过了

pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx 

最终得出结论,不太了解为什么更改了pypi.python.org域。

tried

pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx 

and finally worked out, not quite understand why the domain pypi.python.org is changed.


回答 16

如果通过代理连接,请执行export https_proxy=<your_proxy>(在Unix或Git Bash上),然后重试安装。

如果您使用的是Windows cmd,则更改为set https_proxy=<your_proxy>

If you’re connecting through a proxy, execute export https_proxy=<your_proxy> (on Unix or Git Bash) and then retry installation.

If you’re using Windows cmd, this changes to set https_proxy=<your_proxy>.


回答 17

为了解决此问题,我在Windows 7上执行了以下操作。

c:\ Program Files \ Python36 \ Scripts> pip install beautifulsoup4 –trusted-host *

–trusted-host似乎可以解决SSL问题,*表示每个主机。

当然这是行不通的,因为您会遇到其他错误,因为没有版本可以满足beautifulsoup4的要求,但是我认为该问题与一般性问题无关。

I did the following on Windows 7 to solve this problem.

c:\Program Files\Python36\Scripts> pip install beautifulsoup4 –trusted-host *

The –trusted-host seems to fix the SSL issue and * means every host.

Of course this does not work because you get other errors since there is no version that satisfies the requirement beautifulsoup4, but I don’t think that issue is related to the general question.


回答 18

只需卸载并重新安装将为您锻炼的pip软件包即可。

Mac OS版本:高Sierra 10.13.6

python版本:3.7

因此,我通过输入以下命令卸载了较旧的pip并安装了最新的版本10.0.0:

python3 -m pip uninstall pip setuptools

curl https://bootstrap.pypa.io/get-pip.py | python3

现在我的问题解决了。如果您使用的是python2,则可以将python3替换为python。我希望它也对您有用。

Just uninstall and reinstall pip packages it will workout for you guys.

Mac os version: high Sierra 10.13.6

python version: 3.7

So I uninstalled the older pip and installed the newest version10.0.0 by entering this:

python3 -m pip uninstall pip setuptools

curl https://bootstrap.pypa.io/get-pip.py | python3

Now my problem was solved. If you are using the python2, you can substitute the python3 with python. I hope it also works for you.


回答 19

如果只是关于nltk,我曾经遇到过类似的问题。尝试按照以下安装指南进行操作。 安装NLTK

如果确定它不能与任何其他模块一起使用,则可能是您安装了不同版本的Python时遇到了问题。

或尝试一下,看是否已安装pip 。:

sudo apt-get install python-pip python-dev build-essential 

看看是否可行。

If it is only about nltk, I once faced similar problem. Try following guide for installation. Install NLTK

If you are sure it doesn’t work with any other module, you may have problem with different versions of Python installed.

Or Give It a Try to see if it says pip is already installed.:

sudo apt-get install python-pip python-dev build-essential 

and see if it works.


回答 20

我通过以下步骤解决了此问题(在les 11sp2上)

zypper remove pip
easy_install pip=1.2.1
pip install --upgrade scons

这是puppet中的相同步骤(适用于所有发行版)

  package { 'python-pip':
    ensure => absent,
  }
  exec { 'python-pip':
    command  => '/usr/bin/easy_install pip==1.2.1',
    require  => Package['python-pip'],
  }
  package { 'scons': 
    ensure   => latest,
    provider => pip,
    require  => Exec['python-pip'],
  }

I solved this issue with the following steps (on sles 11sp2)

zypper remove pip
easy_install pip=1.2.1
pip install --upgrade scons

Here are the same steps in puppet (which should work on all distros)

  package { 'python-pip':
    ensure => absent,
  }
  exec { 'python-pip':
    command  => '/usr/bin/easy_install pip==1.2.1',
    require  => Package['python-pip'],
  }
  package { 'scons': 
    ensure   => latest,
    provider => pip,
    require  => Exec['python-pip'],
  }

回答 21

在Mac Python 2.7.15rc1上使用python的最新版本 https://bugs.python.org/issue17128

Use Latest version of python on mac Python 2.7.15rc1 https://bugs.python.org/issue17128


回答 22

我在PyCharm中遇到了这个问题,将点子升级到10.0.1时,出现了“在模块中找不到’main’的错误”点子。

我可以通过安装pip 9.0.3来解决此问题,如在其他一些线程中所见。这些是我执行的步骤:

  1. https://pypi.org/simple/pip/下载了9.0.3版本的pip (因为无法使用pip进行安装)。
  2. 从tar.gz安装pip 9.0.3 python -m pip安装pip-9.0.3.tar.gz

此后,一切开始起作用。

I had this with PyCharm and upgrading pip to 10.0.1 broke pip with “‘main’ not found in module” error.

I could solve this problem by installing pip 9.0.3 as seen in some other thread. These are the steps I did:

  1. Downloaded 9.0.3 version of pip from https://pypi.org/simple/pip/ (since pip couldn’t be used to install it).
  2. Install pip 9.0.3 from tar.gz python -m pip install pip-9.0.3.tar.gz

Everything started to work after that.


回答 23

该视频教程对我有用:

$ curl https://bootstrap.pypa.io/get-pip.py | python

This video tutorial worked for me:

$ curl https://bootstrap.pypa.io/get-pip.py | python

回答 24

我通过在Mac上更新Python3 Virtualenv解决了此问题。我引用了网站https://gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
brew install python3
pip3 install virtualenv

I solved this issue by update Python3 Virtualenv on my mac. I reference the site https://gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
brew install python3
pip3 install virtualenv


回答 25

我尝试了一些流行的答案,但是仍然无法使用安装任何库/软件包pip install

我的特定错误是'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain使用Windows Miniconda(安装程序Miniconda3-py37_4.8.3-Windows-x86.exe)。

当我这样做时,它终于可以工作了: pip install -r requirements.txt --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

具体来说,我添加了它以使其工作: --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

I tried some of the popular answers, but still could not install any libraries/packages using pip install.

My specific error was 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain using Miniconda for Windows (installer Miniconda3-py37_4.8.3-Windows-x86.exe).

It finally works when I did this: pip install -r requirements.txt --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

Specifically, I added this to make it work: --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org