安装几乎所有库的 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.

对这个问题有什么想法吗?我真的很感激一些关于如何让 pip 工作或同时解决问题的反馈。

原文由 contentclown 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 436
1 个回答

我发现将 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.html 和 https //bugs.python.org/issue17128

2019 年 2 月更新:对于某些人来说,升级 pip 可能就足够了。如果上述错误阻止您这样做,请使用 get-pip.py。例如在 Linux 上,

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

更多详细信息,请访问 https://pip.pypa.io/en/stable/installing/

原文由 Oliver 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题