AttributeError: module ‘lib’ has no attribute ‘X509_up_ref’
主要原因是系统当前的python和pyOpenSSL版本不对应
解决办法
卸载再重装pyOpenSSL
pip uninstall pyOpenSSL
pip install pyOpenSSL
No matter what module I try to install via pip3 install I always get the same error :
AttributeError: module 'lib' has no attribute 'X509_up_ref'
Have no idea how to solve this one. Anyone had this issue before?
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
The same error while trying to install a different module:
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
I run Ubuntu 17.10 . I have both python 2.7 and 3.6
Thank you.
This is what resolved it for me:
as root on Debian:
apt remove python3-openssl -y
apt autoremove
Made sure that /usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py was removed.
apt install python3-openssl -y
Then, pip3 was able to install again, and I lived happily ever after.
参考:https://unix.stackexchange.com/questions/438595/attributeerror-module-lib-has-no-attribute-x509-up-ref
https://blog.csdn.net/mouday/article/details/80242597