安装几乎所有库的pip问题

2024-04-20 08:34:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我很难使用pip来安装几乎任何东西。我对编码还不太熟悉,所以我想这可能是我做错了的事情,我选择了简单的安装来完成我所需要的大部分工作,这通常是有效的。不过,现在我正在尝试下载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.

对这个问题有什么想法吗?我真的很感谢你给我一些反馈,告诉我怎样才能让pip工作,或者同时做些什么来解决这个问题。


Tags: pipthetourlsslformorelibrary
3条回答

我发现它足以将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_版本错误的人:它与OP的可信主机/验证问题或此答案无关。相反,TLS v1错误是因为您的解释器不支持TLSV1.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月: 对某些人来说,升级pip可能就足够了。如果上述错误阻止您执行此操作,请使用get-pip.py。E、 g.在Linux上

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

更多详情请参见https://pip.pypa.io/en/stable/installing/

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

你需要重新安装Pip,do

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

或者对于全局Python:

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

我使用了pip版本9.0.1,但有一个相同的问题,上面的所有答案都不能解决问题,而且由于其他原因,我无法在brew中安装python/pip。

将pip升级到9.0.3解决了这个问题。因为我不能用pip升级pip,所以我下载了源代码并手动安装。

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

或者可以使用以下命令安装较新的pip:

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

相关问题 更多 >