pip 安装几乎所有库时都会出现问题
- 2025-03-18 08:54:00
- admin 原创
- 50
问题描述:
我很难使用 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 工作或在此期间解决此问题的反馈。
解决方案 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=13539034、http://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/。
解决方案 2:
我使用了 pip 版本9.0.1
并遇到了同样的问题,以上所有答案都没有解决问题,并且由于其他原因我无法使用 brew 安装 python/pip。
升级 pip9.0.3
解决了这个问题。由于我无法使用 pip 升级 pip,所以我下载了源代码并手动安装。
从https://pypi.org/simple/pip/下载正确版本的 pip
sudo python3 pip-9.0.3.tar.gz
-安装pip
或者你可以使用以下命令安装较新的 pip:
curl https://bootstrap.pypa.io/get-pip.py | python
解决方案 3:
解决方案- 通过在以下主机上标记受信任来安装任何软件包
pypi.python.org
pypi.org
文件.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
解决方案 4:
Pypi 取消了对 TLS 版本低于 1.2 的支持
您需要重新安装 Pip,请执行以下操作
curl https://bootstrap.pypa.io/get-pip.py | python
或者对于全局 Python:
curl https://bootstrap.pypa.io/get-pip.py | sudo python
解决方案 5:
我使用了 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
它对我不起作用。
因此我卸载了旧版 pip,并10.0.0
通过输入以下命令安装了最新版本:
python3 -m pip uninstall pip setuptools
curl https://bootstrap.pypa.io/get-pip.py | python3
现在我的问题解决了。如果你使用的是 python2,你可以用 python 替换 python3。我希望它也适用于你。
顺便说一句,对于像我这样的一些新手,你必须输入代码:sudo -i
获得根权:)祝你好运!
解决方案 6:
您可能看到了这个错误;另请参见此处。
最简单的解决方法是将 pip 降级为不使用 SSL 的版本:easy_install pip==1.2.1
。这样你就失去了使用 SSL 的安全优势。真正的解决方案是使用链接到较新 SSL 库的 Python 发行版。
解决方案 7:
我尝试了一些流行的答案,但仍然无法使用安装任何库/包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
解决方案 8:
SSL 错误的另一个原因可能是系统时间错误——如果距离现在太远,证书将无法验证。
解决方案 9:
对我有用的唯一解决方案是:
sudo curl https://bootstrap.pypa.io/get-pip.py | sudo python
解决方案 10:
--trusted-host pypi.python.org
我通过添加选项解决了类似的问题
解决方案 11:
正如 blackjar 上面所说,下面的几行对我有用
pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx
您需要提供全部三个--trusted-host options
。查看答案后,我尝试只提供第一个,但对我来说不起作用。
解决方案 12:
要安装任何其他软件包,我必须使用最新版本的 pip,因为它9.0.1
存在此 SSL 问题。要通过 pip 本身升级 pip,我必须先解决此 SSL 问题。为了跳出这个无限循环,我发现这是唯一适合我的方法。
在此页面中查找 pip 的最新版本:
https://pypi.org/simple/pip/下载
.whl
最新版本的文件。使用 pip 安装最新的 pip。(此处使用您自己的最新版本)
sudo pip 安装 pip-10.0.1-py2.py3-none-any.whl
现在 pip 是最新版本,可以安装任何东西。
解决方案 13:
macOS Sierra 10.12.6。无法通过 pip 安装任何东西(python 通过 homebrew 安装)。以上所有答案均无效。
最终,从 python 3.5 升级到 3.6 成功了。
brew update
brew doctor #(in case you see such suggestion by brew)
然后按照 brew 的任何其他建议进行操作,例如覆盖到 python 的链接。
解决方案 14:
我遇到了同样的问题。我刚刚将 python 从2.7.0更新到2.7.15。它解决了该问题。
您可以在此处下载。
解决方案 15:
尝试过
pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx
最后终于搞清楚了,不太明白为什么域名pypi.python.org被改变了。
解决方案 16:
您也可以使用 conda 来安装包:请参阅http://conda.pydata.org
conda install nltk
使用 conda 的最佳方式是下载 Miniconda,但您也可以尝试
pip install conda
conda init
conda install nltk
解决方案 17:
对我来说,如果你告诉最新的 pip(1.5.6)不要对安全性太挑剔,它就可以很好地与不安全的 nltk 包配合使用:
pip install --upgrade --force-reinstall --allow-all-external --allow-unverified ntlk nltk
解决方案 18:
如果您通过代理连接,请执行export https_proxy=<your_proxy>
(在 Unix 或 Git Bash 上),然后重试安装。
如果您使用 Windows cmd,则会更改为set https_proxy=<your_proxy>
。
解决方案 19:
我在 Windows 7 上执行以下操作来解决这个问题。
c:\Program Files\Python36\Scripts> pip install beautifulsoup4 --trusted-host *
--trusted-host 似乎修复了 SSL 问题,* 表示每个主机。
当然,这是行不通的,因为没有满足 beautifulsoup4 要求的版本,所以您会收到其他错误,但我不认为该问题与一般问题有关。
解决方案 20:
只需卸载并重新安装 pip 包,它就会为你们解决问题。
Mac OS版本:High 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,你可以用 python 替换 python3。我希望它也适用于你。
解决方案 21:
我通过在我的 Mac 上更新 Python3 Virtualenv 解决了这个问题。我参考了网站https://gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
brew install python3
pip3 install virtualenv
解决方案 22:
我在安装软件包时遇到了同样的问题,并找到了我的情况的原因...似乎我在 Windows 上运行了第三方“媒体下载程序”,它充当所有 SSL 流量的中间人,因此它可以拦截和下载视频等...当我尝试 Pycharm 失败的 URL 时,我可以看到这一点:
无法获取 URL https://pypi.org/simple/pip/:确认 SSL 证书时出现问题:
在浏览器中输入https://pypi.org/simple/pip/并将鼠标悬停在 SSL 区域上 - 它会显示“已由您的下载程序验证”而不是“已由 Verisign 验证”
切断中间人的进攻!
解决方案 23:
如果只是关于 nltk,我也曾经遇到过类似的问题。请尝试按照以下指南进行安装。
安装 NLTK
如果您确定它不能与任何其他模块一起使用,则您可能在安装不同版本的 Python 时遇到了问题。
或者尝试一下,看看它是否显示 pip 已安装:
sudo apt-get install python-pip python-dev build-essential
看看它是否有效。
解决方案 24:
我通过以下步骤解决了这个问题(在 sles 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'],
}
解决方案 25:
在 Mac 上使用最新版本的 Python Python 2.7.15rc1
https://bugs.python.org/issue17128
解决方案 26:
我在使用 PyCharm 时遇到了这个问题,将 pip 升级到 10.0.1 后,pip 出现“模块中未找到‘main’”错误。
我可以通过安装 pip 9.0.3 来解决这个问题,就像在其他线程中看到的那样。这些是我执行的步骤:
从https://pypi.org/simple/pip/下载了 9.0.3 版本的 pip (因为无法使用 pip 来安装它)。
从 tar.gz 安装 pip 9.0.3 python -m pip install pip-9.0.3.tar.gz
此后,一切都开始顺利起来。
解决方案 27:
这个视频教程对我有用:
$ curl https://bootstrap.pypa.io/get-pip.py | python
解决方案 28:
尝试安装 xcode,然后使用 homebrew 使用“brew install pipenv”安装 pipenv。
解决方案 29:
REQUESTS_CA_BUNDLE
对我来说,我必须取消设置必须添加的变量才能使hvac
模块正常工作。有关更多信息,请查看:https://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification。
扫码咨询,免费领取项目管理大礼包!