问题描述
我在Linux上完成了pip的安装,pip list
命令有效.但是使用pip install
命令时,出现以下错误:
I finished installing pip on linux, the pip list
command works. But when using the pip install
command it got the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/commands/install.py", line 339, in run
requirement_set.prepare_files(finder)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/req/req_set.py", line 333, in prepare_files
upgrade=self.upgrade,
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/index.py", line 305, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/index.py", line 783, in _get_page
return HTMLPage.get_page(link, req, session=self.session)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/index.py", line 872, in get_page
"Cache-Control": "max-age=600",
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/sessions.py", line 473, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/download.py", line 365, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/cachecontrol/adapter.py", line 43, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 518, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 322, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 727, in _validate_conn
conn.connect()
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 254, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/local/lib/python2.7/ssl.py", line 350, in wrap_socket
_context=self)
File "/usr/local/lib/python2.7/ssl.py", line 537, in __init__
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname
我该如何解决?
推荐答案
pip 6.1.0 具有已发布,解决了此问题.您可以升级:
pip 6.1.0 has been released, fixing this issue. You can upgrade with:
pip --trusted-host pypi.python.org install -U pip
进行自我升级.
原始答案:
这是由于Python 2.7.9的更改引起的,urllib3
需要对此进行说明.请参阅该项目的问题#543 .您的OpenSSL库不支持SNI,这意味着urllib3
不会将主机名传递给SSL套接字包装器,但是Python 2.7.9希望无论如何出于不同的目的传递主机名.
This is caused by a change in Python 2.7.9, which urllib3
needs to account for. See issue #543 for that project. Your OpenSSL libraries do not support SNI, which means urllib3
won't pass in the host name to the SSL socket wrapper, but Python 2.7.9 expects the hostname to be passed in anyway for different purposes.
urllib3
由requests
间接使用(请参见 requests
问题2435 ), pip
正在使用转弯.
urllib3
is indirectly used by requests
(see requests
issue 2435), which in turn is being used by pip
.
我已经打开了门票,以便从pip
的角度进行跟踪.
I've opened a ticket to track this from pip
's perspective.
潜在问题已由项目维护人员修复,正在等待新版本发布.如果您不耐烦,可以安装pip
的当前开发版本:
The underlying issues have been fixed by the project maintainers, and awaiting a new release. You could install the current development version of pip
if you are impatient:
pip install --trusted-host=github.com -U https://github.com/pypa/pip/archive/develop.zip
这将安装pip-6.1.0.dev0,当6.1.0完全发布时,您可以再次使用pip install -U pip
进行升级,以从PyPI获得最终版本.
This'll install pip-6.1.0.dev0, when 6.1.0 is fully released you can upgrade again with pip install -U pip
to get the final release from PyPI.
这篇关于Python pip安装需要server_hostname的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!