在更新到Ubuntu 18.04 LTS之后,我不能再使用大多数Python应用程序,包括pip(安装或卸载)。我在命令行中收到以下错误:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 572, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2755, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2408, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2414, in resolve
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
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 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
在搜索错误之后,看来pyopenssl
的版本已过时,但是我尝试通过TGZ文件或easy_install手动下载安装pyopenssl18
,但都没有起作用。
由于出现上述错误,我无法通过pip安装/卸载。有什么建议么?我想避免重新安装Python甚至操作系统本身。
答案 0 :(得分:0)
再次尝试手动安装pyopenssl 18后,我注意到它的安装路径为:/usr/local/lib/python2.7/dist-packages
所以我去了那个目录,看到了一个名为:
的文件夹。OpenSSL
错误中引用的。我重命名了该文件夹,然后重新安装了pyopenssl,错误已清除。我访问HTTPS站点没有任何问题,因此这可能是被pyOpenSSL取代的已弃用的模块吗?