解决方案之AttributeError: module ‘lib‘ has no attribute ‘Cryptography_HAS_SSL_ST‘

问题描述:

$ pip3
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in 
    from pip._internal import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/__init__.py", line 42, in 
    from pip._internal import cmdoptions
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cmdoptions.py", line 16, in 
    from pip._internal.index import (
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/index.py", line 15, in 
    from pip._vendor import html5lib, requests, six
  File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/requests/__init__.py", line 86, in 
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in 
    import OpenSSL.SSL
  File "/usr/local/lib/python3.5/dist-packages/OpenSSL/__init__.py", line 8, in 
    from OpenSSL import crypto, SSL
  File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 194, in 
    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

参考链接:
http://www.itdaan.com/blog/2016/12/12/59de61db4a86cdfd6599ecf447ee950d.html

你可能感兴趣的:(python)