AttributeError: module 'lib' has no attribute 'Cryptography_HAS_SSL_ST'
,报错信息及解决方法如下:具体状况为:导入模块正常,但在执行python程序时会报错,导致程序不能正常运行。
报错信息:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 194, in <module>
if _lib.Cryptography_HAS_SSL_ST:
AttributeError: module 'lib' has no attribute 'Cryptography_HAS_SSL_ST'
解决方案:
我可以通过删除openssl python库并重新安装(安装前清除无效)来解决这个问题:
$ sudo rm -rf /usr/local/lib/python3.5/dist-packages/OpenSSL/
$ sudo apt install --reinstall python-openssl