安装请求后 Pip 损坏 [安全]

Pip broken after installing requests[security]

运行之后 pip install requests[security] 运行 任何 pip 命令都会输出以下错误。我试过 apt-get 删除并重新安装 python-pip 以及 python-pyopenssl。想知道是否有人对这个问题有建议或 运行?我无法升级 python 或 Debian,但想让 pip 再次工作。

Debian 6.0.10
Python2.6.6
python-点 1.5.6

$ pip --version
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 305, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2244, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python2.6/dist-packages/pip-1.5.6-py2.6.egg/pip/__init__.py", line 11, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/local/lib/python2.6/dist-packages/pip-1.5.6-py2.6.egg/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/local/lib/python2.6/dist-packages/pip-1.5.6-py2.6.egg/pip/download.py", line 22, in <module>
    from pip._vendor import requests, six
  File "/usr/local/lib/python2.6/dist-packages/pip-1.5.6-py2.6.egg/pip/_vendor/requests/__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.6/dist-packages/pip-1.5.6-py2.6.egg/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 49, in <module>
    from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT
  File "/usr/local/lib/python2.6/dist-packages/ndg/httpsclient/ssl_peer_verification.py", line 14, in <module>
    from ndg.httpsclient.subj_alt_name import SubjectAltName
  File "/usr/local/lib/python2.6/dist-packages/ndg/httpsclient/subj_alt_name.py", line 102, in <module>
    class AnotherName(univ.Sequence):
  File "/usr/local/lib/python2.6/dist-packages/ndg/httpsclient/subj_alt_name.py", line 105, in AnotherName
    namedtype.NamedType('value', univ.Any().subtype(
AttributeError: 'module' object has no attribute 'Any'

只需执行以下操作即可解决此问题: sudo apt-get autoremove

不幸的是,sudo apt-get autoremove 并没有神奇地发生删除。当然我也试过标准的pip uninstall ndg-httpsclient先不走运

最后只好进入python程序目录强行删除

$ cd usr/local/lib/python2.7/dist-packages
$ sudo rm -rf ndg_httpsclient-0.3.3-py2.7.egg-info
$ sudo rm -rf ndg_httpsclient-0.3.3-py2.7-nspkg.pth
$ sudo rm -rf ndg

请在此处引用此错误:https://github.com/cedadev/ndg_httpsclient/issues/5

I suspect the problem is that pip on Ubuntu is using ndg_httpsclient, and the current ndg_httpsclient conflicts with the old pyasn1, so pip breaks during installation.

Anyway, valid versions of pyasn1 to choose from are : 0.0.9a0, 0.0.10a0, 0.0.11a0, 0.0.12a0, 0.0.13a0, 0.0.13b0, 0.0.13, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9

And I have found a semi-reasonable workaround to the problem.

However 0.0.13 doesnt install on Python 3, so I think the minimum should be at least 0.1.1.

However I see that cryptography requires pyasn1>=0.1.8 , so it is likely most people will be using that soon.