我是Python的新手,并尝试在Windows 7上使用> pip install linkchecker
。一些注意事项:
> pip install scrapy
也会导致SSL错误。python
和pip
无法从命令行获得。> pip search linkchecker
的作品。也许这是因为pip搜索不会验证网站的SSL证书。以下是运行pip install linkchecker
后我的pip.log的内容:
Downloading/unpacking linkchecker
Getting page https://pypi.python.org/simple/linkchecker/
Could not fetch URL https://pypi.python.org/simple/linkchecker/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
Will skip URL https://pypi.python.org/simple/linkchecker/ when looking for download links for linkchecker
Getting page https://pypi.python.org/simple/
Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/ (Caused by <class 'http.client.CannotSendRequest'>: Request-sent)
Will skip URL https://pypi.python.org/simple/ when looking for download links for linkchecker
Cannot fetch index base URL https://pypi.python.org/simple/
URLs to search for versions for linkchecker:
* https://pypi.python.org/simple/linkchecker/
Getting page https://pypi.python.org/simple/linkchecker/
Could not fetch URL https://pypi.python.org/simple/linkchecker/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
Will skip URL https://pypi.python.org/simple/linkchecker/ when looking for download links for linkchecker
Could not find any downloads that satisfy the requirement linkchecker
Cleaning up...
Removing temporary dir C:\Users\jcook\AppData\Local\Temp\pip_build_jcook...
No distributions at all found for linkchecker
Exception information:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1177, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "C:\Python34\lib\site-packages\pip\index.py", line 277, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
pip.exceptions.DistributionNotFound: No distributions at all found for linkchecker
您可以通过将pypi.org
和files.pythonhosted.org
设置为可信主机来忽略SSL错误。
$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
注意:2018年4月的某个时候,Python Package Index从pypi.python.org
迁移到pypi.org
。这意味着使用旧域的“trusted-host”命令不再起作用。
自从pip 10.0发布以来,你应该能够通过升级pip
本身来永久修复它:
$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools
或者通过reinstalling it获取最新版本:
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
(...然后使用相关的Python解释器运行get-pip.py
)。
pip install <otherpackage>
应该在此之后工作。如果没有,那么您将需要做更多,如下所述。
你可能想要add the trusted hosts and proxy to your config file。
pip.ini
(Windows)或pip.conf
(unix)
[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
替代解决方案(不太安全)
大多数答案可能会带来安全问题。
有助于轻松安装大多数python包的两个解决方法是:
easy_install <package_name>
。请注意,找不到某些包或会出现小错误。pip install wheel_package_name.whl
安装软件包。您可以尝试使用http而不是https来绕过SSL错误。当然,这在安全性方面并不是最优的,但是如果你赶时间应该这样做:
easy_install
使用的答案
pip install --index-url=http://pypi.python.org/simple/ linkchecker
工作。但你必须检查是否有重定向或缓存pip install --trusted-host pypi.python.org <package>
正在击中。在使用pip
的Windows 7上,我必须运行
pip 9.0.1
您可以使用详细标记找到这些。
对我而言,我的日期和时间在Raspberry Pi上配置错误。结果是所有SSL和HTTPS连接都失败了,使用pip install \
--trusted-host pypi.python.org \
--trusted-host pypi.org \
--trusted-host files.pythonhosted.org \
<package>
服务器。
https://files.pythonhosted.org/
参考:sudo date -s "Wed Thu 23 11:12:00 GMT+1 2018"
sudo dpkg-reconfigure tzdata
https://superuser.com/a/635024/935136
我使用easy_install安装了pip 1.2.1并升级到最新版本的pip(当时为6.0.7),它可以在我的情况下安装软件包。
sudo date -s "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')"
sudo dpkg-reconfigure tzdata
永久修复
easy_install pip==1.2.1
pip install --upgrade pip
例如:
pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org
首先,
pip install <package name> --trusted-host pypi.org --trusted-host files.pythonhosted.org
不适合我。我一直收到CERTIFICATE_VERIFY_FAILED错误。但是,我在错误消息中注意到他们引用了“pypi.org”网站。所以,我使用它作为可信主机名而不是pypi.python.org。那几乎让我在那里;使用CERTIFICATE_VERIFY_FAILED,负载仍然失败,但稍后。找到对失败的网站的引用,我将其作为可信主机包含在内。最终对我有用的是:
pip install --trusted-host pypi.python.org <package name>
你有4个选择:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package name>
$ pip install --cert /path/to/mycertificate.crt linkchecker
创建此文件:
pip.conf
并添加以下行:
$HOME/.pip/pip.conf (Linux)
%HOME%\pip\pip.ini (Windows)
[global]
cert = /path/to/mycertificate.crt
创建此文件:
$ pip install --trusted-host pypi.python.org linkchecker
并添加以下行:
$HOME/.pip/pip.conf (Linux)
%HOME%\pip\pip.ini (Windows)
[global]
trusted-host = pypi.python.org
在64位Windows 7企业版上使用ActivePython 2.7.8,ActivePython 3.4.1和“stock”Python 3.4.2尝试https://pip.pypa.io/en/latest/user_guide/#configuration时遇到同样的问题。所有尝试都失败,出现与OP相同的错误。
通过降级到pip 1.2.1来解决Python 3.4.2的问题:pip install ftputil
(参见easy_install pip==1.2.1
)。同样的修复也适用于ActivePython 2.7.8。
2013年3月报道的这个漏洞仍然是开放的:https://stackoverflow.com/a/16370731/234235。
在我使用--verbose选项查看它想要访问files.pythonhosted.org而不是pypi.python.org之前,此页面上的任何内容都不适用于我:
https://github.com/pypa/pip/issues/829
因此,请通过--verbose选项检查其实际失败的URL。
我解决了这个问题,删除了我的点子并安装旧版本的pip:pip install --trusted-host files.pythonhosted.org <package_name>
您可以使用此参数指定证书:
pip --cert /etc/ssl/certs/FOO_Root_CA.pem install linkchecker
见:Docs » Reference Guide » pip
如果指定您公司的根证书不起作用,那么cURL可能会起作用:http://curl.haxx.se/ca/cacert.pem
您必须使用PEM文件而不是CRT文件。如果你有一个CRT文件,你将需要convert the file to PEM评论中有报告说这现在适用于CRT文件,但我还没有验证。
还要检查:SSL Cert Verification。
您可以尝试忽略“https”:
https://pypi.python.org/pypi/pip/1.2.1
对我来说这是因为以前我正在运行脚本设置代理(到fiddler),重新打开控制台或重新启动修复问题。
最近我在使用Visual Studio 2015的python 3.6中遇到了同样的问题。花了2天后,我得到了解决方案,并且它对我来说很好。
我尝试使用pip或从visual studio安装numpy时出现以下错误收集numpy无法获取URL pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org [your package..]
:确认ssl证书时出现问题:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:748) - 跳过可能找不到满足要求numpy的版本(来自版本:)没有为numpy找到匹配的发行版
解析度 :
向前AS
https://pypi.python.org/simple/numpy/回答帮助了我。
我没有在我的电脑上找到pip.ini文件。以下是如此。
或者只需在Windows资源管理器中键入%AppData%。
pip.ini文件:
你现在应该好好去。
一个解决方案(对于Windows)是在[list]
format=columns
[global]
trusted-host = pypi.python.org pypi.org
文件夹上创建一个名为pip.ini
的文件(如果该文件夹不存在则创建该文件夹)并插入以下详细信息:
%AppData%\pip\
...然后我们可以执行安装指令:
[global]
cert = C:/certs/python_root.pem
proxy = http://my_user@my_company.com:my_password@proxy_ip:proxy_port
另一个选择是使用代理和证书的参数安装包...
pip3 install PyQt5
要将证书$ pip3 install --proxy http://my_user@my_company.com:my_password@proxy_ip:proxy_port \
--cert C:/certs/python_root.pem PyQt5
文件转换为所需的*.cer
格式,请执行以下指令:
*.pem
希望这有助于某人!
我不确定这是否相关,但是我有一个类似的问题,通过将这些文件从Anaconda3 / Library / bin复制到Anaconda3 / DLL来修复:
libcrypto-1_1-x64.dll
的libssl-1_1-x64.dll
对我来说,没有一个建议的方法有效 - 使用cert,HTTP,trusted-host。
在我的情况下切换到不同版本的包工作(在这个例子中paho-mqtt 1.3.1而不是paho-mqtt 1.3.0)。
看起来问题特定于该软件包版本。
就我而言,我在最小的阿尔卑斯山泊码头图像中运行Python。它缺少根CA证书。固定:
$ openssl x509 -inform der -in python_root.cer -out python_root.pem
如果您的system.eg中缺少某些证书,则openuse install ca-certificates-mozilla可能会出现此问题
截至目前,当pip升级到10时,现在他们已经将路径从pypi.python.org更改为files.pythonhosted.org请将命令更新为pip --trusted-host files.pythonhosted.org安装python_package
kenorb’s answer非常有用(太棒了!)。
在他的解决方案中,也许这是最简单的一个:--trusted-host
例如,在这种情况下,您可以这样做
pip install --trusted-host pypi.python.org linkchecker
pem文件(或其他任何东西)是不必要的。
如果您使用apk update && apk add ca-certificates
手动安装Python,则必须遵循以下答案:make
才能使其正常工作。
答案非常相似,有点令人困惑。就我而言,我公司网络中的证书就是问题所在。我能够使用以下方法解决问题:
pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org oauthlib -vvv
qazxsw poi。如果不需要详细输出,则可以省略-vvv参数
我发现最直接的方法是从As seen here下载并使用DigiCert的“DigiCert High Assurance EV Root CA”
您可以通过单击地址栏中的锁定图标来访问https://www.digicert.com/digicert-root-certificates.htm#roots以验证证书颁发者,或使用openssl增加您的极客信誉:
https://pypi.python.org/
证书链中的最后一个CN值是您需要下载的CA的名称。
对于一次性工作,请执行以下操作:
$ openssl s_client -connect pypi.python.org:443
CONNECTED(00000003)
depth=1 /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/businessCategory=Private Organization/1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/serialNumber=3359300/street=16 Allen Rd/postalCode=03894-4801/C=US/ST=NH/L=Wolfeboro,/O=Python Software Foundation/CN=www.python.org
i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA
1 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA
i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
(在运行pip之前,最后一行假定您使用的是bash shell)。
CRT
为了使其可重复使用,将DigiCertHighAssuranceEVRootCA.crt置于常用位置,并在〜/ .bashrc中相应地导出PIP_CERT。
要一劳永逸地解决这个问题,您可以验证您是否有curl -sO http://cacerts.digicert.com/DigiCertHighAssuranceEVRootCA.crt
openssl x509 -inform DES -in DigiCertHighAssuranceEVRootCA.crt -out DigiCertHighAssuranceEVRootCA.pem -text
export PIP_CERT=`pwd`/DigiCertHighAssuranceEVRootCA.pem
文件。
根据pip.conf
,这是你的pip.conf
应该是的地方:
在Unix上,默认配置文件是:documentation,它尊重XDG_CONFIG_HOME环境变量。
在macOS上配置文件是
$HOME/.config/pip/pip.conf
如果目录$HOME/Library/Application Support/pip/pip.conf
存在其他$HOME/Library/Application Support/pip
在Windows上,配置文件是
$HOME/.config/pip/pip.conf
。
在virtualenv里面:
在Unix和macOS上,文件是
%APPDATA%\pip\pip.ini
在Windows上,文件是:
$VIRTUAL_ENV/pip.conf
你的%VIRTUAL_ENV%\pip.ini
应该是这样的:
pip.conf
[global]
trusted-host = pypi.python.org
在创建pip install linkchecker
文件后没有抱怨就安装了linkchecker
。
对我来说,问题是通过在pip.conf
中创建一个文件夹pip
来修复的:pip.ini
例如:
C:\Users\<username>\AppData\Roaming\
在里面我写道:
C:\Users\<username>\AppData\Roaming\pip\pip.ini
我重新启动了python,然后pip永久信任这些网站,并用它们从中下载包。
您有以下可能性来解决[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
的问题:
CERTIFICATE_VERIFY_FAILED
或--cert <trusted.pem>
变量指定备用CA包。
例如。您可以从Web浏览器转到失败的URL并将根证书导入您的系统。CA_BUNDLE
以检查当前的(验证是否存在)。python -c "import ssl; print(ssl.get_default_verify_paths())"
,SSL_CERT_DIR
),可用于指定不同的证书databaseSSL_CERT_FILE
。--trusted-host <hostname>
作为verify=False
(参见:requests.get
)。阅读更多:--proxy <proxy>
。
我最近遇到了这个问题,因为我公司的Web内容过滤器使用自己的证书颁发机构,因此它可以过滤SSL流量。在我的情况下,PIP似乎没有使用系统的CA证书,产生您提到的错误。将PIP降级到版本1.2.1后面会出现一系列问题,所以我回到了Python 3.4附带的原始版本。
我的解决方法很简单:使用TLS/SSL wrapper for socket objects - Verifying certificates。要么它不检查证书(如旧的PIP版本),要么它知道使用系统证书,因为它每次都适用于我,我仍然可以使用PIP卸载使用easy_install安装的软件包。
如果这不起作用并且您可以访问没有问题的网络或计算机,您可以随时设置自己的个人PyPI服务器:easy_install
我几乎这样做,直到我尝试使用how to create local own pypi repository index without mirror?作为最后的努力。