AttributeError:模块“lib”没有属性“X509_up_ref”

Gab*_*tte 6 ubuntu python pip

无论我尝试通过 pip3 install 安装什么模块,我总是遇到相同的错误:

AttributeError: module 'lib' has no attribute 'X509_up_ref'
Run Code Online (Sandbox Code Playgroud)

不知道如何解决这个问题。以前有人遇到过这个问题吗?

gabriel@E1-522:~$ pip3 install ipaddress

Collecting ipaddress

From cffi callback <function _verify_callback at 0x7f0d2e0419d8>:

Traceback (most recent call last):

File "/usr/local/lib/python3.6/dist-packages/OpenSSL/SSL.py", line 313, 

in wrapper

_lib.X509_up_ref(x509)

AttributeError: module 'lib' has no attribute 'X509_up_ref'

Could not find a version that satisfies the requirement ipaddress 
(from versions: )

No matching distribution found for ipaddress
Run Code Online (Sandbox Code Playgroud)

尝试安装不同的模块时出现相同的错误:

gabriel@E1-522:~$ pip3 install cryptography

Collecting cryptography

From cffi callback <function _verify_callback at 0x7fd515d659d8>:

Traceback (most recent call last):

File "/usr/local/lib/python3.6/dist-packages/OpenSSL/SSL.py", line 313, in wrapper

_lib.X509_up_ref(x509)

AttributeError: module 'lib' has no attribute 'X509_up_ref'

Could not find a version that satisfies the requirement cryptography 

(from versions: )

No matching distribution found for cryptography
Run Code Online (Sandbox Code Playgroud)

我运行 Ubuntu 17.10 。我有 python 2.7 和 3.6

谢谢。

小智 6

我尝试运行sudo /usr/bin/certbot renew,但失败并出现 X509_up_ref 错误。这解决了我的问题。

sudo pip install pyOpenSSL --upgrade
Run Code Online (Sandbox Code Playgroud)

当你在使用加密模块时,可能不会有什么坏处。

sudo pip install cryptography --upgrade
Run Code Online (Sandbox Code Playgroud)

我认为这就是@hoefling 早些时候想要表达的意思,但我有点慢,必须把它拼写出来才能得到它。正如他指出的那样,双方都需要与时俱进才能相处融洽。certbot renew 命令在升级后立即生效。


小智 2

这就是为我解决的问题:

作为 Debian 上的 root:

apt remove python3-openssl -y apt autoremove

确保/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py已将其删除。

apt install python3-openssl -y

然后,pip3又可以安装了,从此我过上了幸福的生活。