使用 pip3

使用 pip3

pipUbuntu 14.04 上,我收到此错误:

Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 4, in <module>
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/__init__.py", line 52, in <module>
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/packages/__init__.py", line 59, in <module>
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/packages/__init__.py", line 32, in vendored
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 47, in <module>
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

我该如何解决这个问题?

答案1

使用 pip3

我不得不改用以下方法来pip3解决这个问题:

$ sudo pip3 install --upgrade pyopenssl

答案2

我找到stackoverflow 上的这个答案有帮助。基本上,它说你应该这样做:

rm -rf /home/<Your Username>/.local/lib/python2.7/site-packages/OpenSSL
sudo rm -rf usr/local/lib/python2.7/dist-packages/OpenSSL/
pip install pyOpenSSL

答案3

是的,pip 会出现错误,直到您手动修复它(提到鸡和蛋)...找到库的安装位置并手动删除它。

在我的 16.04 安装中我这样做了:

cd /usr/lib/python2.7/dist-packages
rm -rf OpenSSL

然后 pip 就可以正常工作,不再出现 SSL 错误

pip 安装 pyopenssl

答案4

您缺少 pyOpenSSL 包,或者其已过时。

只需运行

$ pip install pyopenssl

并更新包(可能没有必要)。

相关内容