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

7,530

Solution 1

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.

Solution 2

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.

Share:
7,530
Gabriel Lafayette
Author by

Gabriel Lafayette

Updated on September 18, 2022

Comments

  • Gabriel Lafayette
    Gabriel Lafayette over 1 year

    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.