使用pip安装包的“SSL证书验证失败”
我正在尝试使用pip为python安装Scrapy包(以及其他)。我已经尝试使用python 3和python 2进行安装,我已经安装/升级了setuptools,如下所示:$ pip3 install --upgrade setuptools
,我试图使用--trusted-host
选项,如下所示:$ pip3 install --trusted-host pypi.python.org Scrapy
。但是当我运行$ pip3 install Scrapy
时,我总是收到相同的错误消息。完整的输出是这样的:使用pip安装包的“SSL证书验证失败”
Collecting Scrapy
Using cached Scrapy-1.3.2-py2.py3-none-any.whl
Collecting PyDispatcher>=2.0.5 (from Scrapy)
Using cached PyDispatcher-2.0.5.tar.gz
Collecting service-identity (from Scrapy)
Using cached service_identity-16.0.0-py2.py3-none-any.whl
Collecting pyOpenSSL (from Scrapy)
Using cached pyOpenSSL-16.2.0-py2.py3-none-any.whl
Collecting w3lib>=1.15.0 (from Scrapy)
Using cached w3lib-1.17.0-py2.py3-none-any.whl
Collecting parsel>=1.1 (from Scrapy)
Using cached parsel-1.1.0-py2.py3-none-any.whl
Collecting queuelib (from Scrapy)
Using cached queuelib-1.4.2-py2.py3-none-any.whl
Requirement already satisfied: six>=1.5.2 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from Scrapy)
Collecting Twisted>=13.1.0 (from Scrapy)
Using cached Twisted-17.1.0.tar.bz2
Complete output from command python setup.py egg_info:
Download error on https://pypi.python.org/simple/incremental/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
Couldn't find index page for 'incremental' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
No local packages or working download links found for incremental>=16.10.1
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/gy/5xt04_452z791v1qjs1yzxkh0000gn/T/pip-build-nkv4jozy/Twisted/setup.py", line 21, in <module>
setuptools.setup(**_setup["getSetupArgs"]())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/dist.py", line 317, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/dist.py", line 372, in fetch_build_eggs
replace_conflicting=True,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 851, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1123, in best_match
return self.obtain(req, installer)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1135, in obtain
return installer(requirement)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/dist.py", line 440, in fetch_build_egg
return cmd.easy_install(req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 668, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('incremental>=16.10.1')
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/gy/5xt04_452z791v1qjs1yzxkh0000gn/T/pip-build-nkv4jozy/Twisted/
我在一个mac操作系统版本10.12.1和我使用python 3.6。 有没有人知道这个问题的解决方案?
如前所述https://bugs.python.org/issue28150在以前版本的python中Apple提供了OpenSSL包,但现在已经不存在了。
运行命令pip install certifi
然后pip install Scrapy
固定对我来说
一些尝试---告诉Python不使用https与索引指令和HTTP://地址(没有使用https://)
pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org Scrapy
你可能是一个企业防火墙和伊夫背后有经验,即使上述失败,但我不会假装我知道足够的防火墙或SSL知道为什么。在那种情况下,我能够解决的唯一方法是获得一个证书文件并将其传递给python。有关详细信息,请参阅kenorb’s answer。
pip install --trusted-host pypi.python.org autopep8 (any package name)
此命令将增加pypi.python.org
的可信来源,并安装所有必需的包。
我自己遇到了错误,输入这个命令帮助我安装了python的所有pip软件包。
你在公司防火墙后面吗? –
可能重复的[pip安装失败,连接错误:\ [SSL:CERTIFICATE \ _VERIFY \ _FAILED \]证书验证失败(\ _ssl.c:598)“](http://stackoverflow.com/questions/25981703/ pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi) gbtimmon
@ Scratch'N'Purr,不,我不是 – imc