Python Version=2.6.6
好的,所以这个让我难过。
首先,这是我尝试安装时的回溯。在这种情况下,我跑了:pip install requests
作为根。注意:我知道这是pip版本7.0.3
。最新版本的pip会出现相同的回溯。
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/commands/install.py", line 291, in run
wb.build(autobuilding=True)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/wheel.py", line 705, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/req/req_set.py", line 317, in prepare_files
functools.partial(self._prepare_file, finder))
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/req/req_set.py", line 304, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/req/req_set.py", line 439, in _prepare_file
req_to_install.populate_link(finder, self.upgrade)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/req/req_install.py", line 244, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/index.py", line 486, in find_requirement
all_versions = self._find_all_versions(req.name)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/index.py", line 404, in _find_all_versions
index_locations = self._get_index_urls_locations(project_name)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/index.py", line 378, in _get_index_urls_locations
page = self._get_page(main_index_url)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/index.py", line 810, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/index.py", line 920, in get_page
"Cache-Control": "max-age=600",
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
conn.connect()
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/usr/lib/python2.6/site-packages/pip-7.0.3-py2.6.egg/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 279, in ssl_wrap_socket
cnx.set_tlsext_host_name(server_hostname)
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
然后我使用pip uninstall pip
卸载了pip并确认删除了egg和二进制文件。然后我使用easy_install pip
重新安装它但没有运气。我也尝试了这个,但使用了最新版本的pip和版本7.0.3
。同样的事情。
此外,安装get-pip.py
会产生这种回溯,这与奇怪的相似:
Traceback (most recent call last):
File "/tmp/tmp0rv6P1/pip.zip/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/tmp/tmp0rv6P1/pip.zip/pip/commands/install.py", line 291, in run
wb.build(autobuilding=True)
File "/tmp/tmp0rv6P1/pip.zip/pip/wheel.py", line 705, in build
self.requirement_set.prepare_files(self.finder)
File "/tmp/tmp0rv6P1/pip.zip/pip/req/req_set.py", line 317, in prepare_files
functools.partial(self._prepare_file, finder))
File "/tmp/tmp0rv6P1/pip.zip/pip/req/req_set.py", line 304, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/tmp/tmp0rv6P1/pip.zip/pip/req/req_set.py", line 387, in _prepare_file
req_to_install, finder)
File "/tmp/tmp0rv6P1/pip.zip/pip/req/req_set.py", line 348, in _check_skip_installed
finder.find_requirement(req_to_install, self.upgrade)
File "/tmp/tmp0rv6P1/pip.zip/pip/index.py", line 486, in find_requirement
all_versions = self._find_all_versions(req.name)
File "/tmp/tmp0rv6P1/pip.zip/pip/index.py", line 404, in _find_all_versions
index_locations = self._get_index_urls_locations(project_name)
File "/tmp/tmp0rv6P1/pip.zip/pip/index.py", line 378, in _get_index_urls_locations
page = self._get_page(main_index_url)
File "/tmp/tmp0rv6P1/pip.zip/pip/index.py", line 810, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/tmp/tmp0rv6P1/pip.zip/pip/index.py", line 920, in get_page
"Cache-Control": "max-age=600",
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/tmp/tmp0rv6P1/pip.zip/pip/download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/adapters.py", line 370, in send
timeout=timeout
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
conn.connect()
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/tmp/tmp0rv6P1/pip.zip/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 279, in ssl_wrap_socket
cnx.set_tlsext_host_name(server_hostname)
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
让我感到困惑的是追溯的最后4行。在分析了追溯之后,我潜入了蛋。
显然,从回溯中,错误来自ssl_wrap_socket
函数,该函数在connection.py
中调用。追溯说ssl_wrap_socket
调用{urlib3_path}/contrib/pyopenssl.py
在45-50
中定义,但是,在查看connection.py
的行# connection.py
from .util.ssl_ import (
resolve_cert_reqs,
resolve_ssl_version,
ssl_wrap_socket,
assert_fingerprint,
)
时:
ssl_wrap_socket
{urllib3_path}/util/ssl_.py
应该从不包含有问题的代码行的pyopenssl
导入,但是根据不是正在发生的回溯。
我不知道发生了什么但是假设这是一些我不知道的关于python的巧妙。如果有人有任何线索请告诉我。
编辑:新发展!
当从github绊倒this bit of the requests code时,似乎请求库实际上将pyopenssl
注入到urllib3库中,该库解释了回溯。但是我仍然不确定如何解决这个问题。
Edit2:解决方案!
原来urllib3库被注入了错误的pyopenssl
!在我发现请求将urllib3
注入pyopenssl.py
库后,我检出了def inject_into_urllib3():
'Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.'
connection.ssl_wrap_socket = ssl_wrap_socket
util.HAS_SNI = HAS_SNI
并找到了此功能:
ssl_wrap_socket
pyopenssl.py
在OpenSSL.SSL
中定义,并依赖于pyOpenSSL-0.15.1-py2.6.egg
。
我跳到site-packages
文件夹中的0.15.1
,只是为了确保检查版本>>> import OpenSSL.SSL as ssl
>>> ssl.__file__
。经过一番思考后,我打开了解释器并运行了
lib64/python2.6/site-packages
其中告诉我,我在OpenSSL
中有一个OpenSSL目录被引用而不是pyOpenSSL
鸡蛋中的0.10
目录,它只是版本instance_double
!这当然是什么导致原始错误被抛出。删除该目录后,Pip似乎没有问题。
答案 0 :(得分:0)
我尝试使用devunt的easy_install代码行,但它没有用。它拒绝访问一堆冲突的python 2.7文件。我基本上和pip有同样的问题。我在Mac OSX上遇到了点数7.0.3并且得到像scikit,numpy和scipy这样的东西,我需要升级到7.1.0。我在Python 2.7.6上,在我尝试下载mysql-python后跟踪错误消息后,我收到了一条错误消息,如图所示,并跟随它来源,这是一个错误消息,因为一个不稳定的系统https'的SSL安全性(即Python 2.7.6)。我的错误信息是:
You are using pip version 7.0.3, however version 7.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/Library/Python/2.7/site-packages/pip-7.0.3 py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting pip
Using cached pip-7.1.0-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 7.0.3
Uninstalling pip-7.0.3:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/commands/install.py", line 297, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_set.py", line 616, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 721, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/utils/__init__.py", line 314, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip- 7.0.3-py2.7.egg/EGG-INFO/dependency_links.txt'
因此,据我所知,这个错误是由与Python 2.7.6上Mac OS X捆绑在一起的不兼容性驱动的。因为Mac上的brew是我过去用来升级python的东西,所以我使用" brew update"当brew更新时,我去了" brew install升级python --upgrade python"完成后我检查了我的版本,如下所示:
John-Mulhalls-MacBook-Pro:Python_DataBase_Project jmulhall$ brew --version
0.9.5
John-Mulhalls-MacBook-Pro:Python_DataBase_Project jmulhall$ python --version
Python 2.7.10
John-Mulhalls-MacBook-Pro:Python_DataBase_Project jmulhall$ pip --version
pip 7.1.0 from /usr/local/lib/python2.7/site-packages (python 2.7)
John-Mulhalls-MacBook-Pro:Python_DataBase_Project jmulhall$
我解决此错误的经验教训是将python升级到2.7.9(我读过有关Pip的先前版本中的错误)或更高版本。 Pip将捆绑Python 2.7.10作为Pip 7.1.0。我成功安装了' brew install mysql-python' 当回到数据科学,决策树和python时,将会安装颠簸,scipy和scikit。希望这有助于兄弟们...... ..