5

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.

2
  • Please instead of putting image write the output codes in a coding formatting
    – sinecode
    Apr 18, 2018 at 20:58
  • 1
    Most probably you have an incompatible version combination of pyopenssl and cryptography installed. If you run pip show cryptography | grep "Version:" and pip show pyopenssl | grep "Version:" , what do you get? Updating both packages to latest versions should solve the issue.
    – hoefling
    May 27, 2018 at 11:39

3 Answers 3

4

I was trying to run sudo /usr/bin/certbot renew and it was failing with the X509_up_ref error. This resolved my issue.

sudo pip install pyOpenSSL --upgrade

Probably wouldn't hurt to do the cryptography module also while your at it.

sudo pip install cryptography --upgrade

I think this is what @hoefling was trying to get at earlier but I'm a bit slow and had to have it spelled out in order to get it. As he pointed out, both need to be up to date to play nice with each other. The certbot renew command worked immediately after upgrading.

1

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.

0

I try the apt remove command but it did not resolve the issue for me. However, we have both pip and pip3 installed. So the following sequence is what fixed it for me:

pip install -U cryptography; 
sudo apt remove python3-openssl -y; 
sudo apt autoremove; 
pip3 install -U cryptography; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.