Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

后端 未结 20 1477
無奈伤痛
無奈伤痛 2020-11-29 02:06

A Python script of mine is failing with:

Traceback (most recent call last):
  File \"./inspect_sheet.py\", line 21, in 
    main()
  File \"./i         


        
相关标签:
20条回答
  • 2020-11-29 02:53

    Update your pyopenssl module:

    $ sudo pip install -U pyopenssl
    
    0 讨论(0)
  • 2020-11-29 02:55

    My problem was caused by the version of Python openssl that was in /usr/lib/python2.7/dist-packages/.

    dpkg -l | grep openssl showed:

    ii  python-openssl                                0.15.1-2build1                               all          Python 2 wrapper around the OpenSSL library
    

    I removed it using sudo apt-get remove python-openssl. I then ran the following to install the distribution version of pip.

    curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
    sudo python2 ./get-pip.py
    

    pip --version now displays:

    pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
    

    I was then able to perform the necessary pip install I was trying to complete.

    0 讨论(0)
  • 2020-11-29 02:55

    I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too.

    Doing

    sudo pip install pyOpenSSL==16.2.0

    resolved it for me.

    0 讨论(0)
  • 2020-11-29 02:55

    My solution was a lot more simplistic after these other solutions not working for me. Anything I tried to install/uninstall via pip returned the same error and stacktrace.

    I ended up trying to update pip via pip3 and it worked flawlessly:

    pip3 install --upgrade pip

    I went back to using pip and everything worked correctly. I did notice that it was referencing Python 3.6 when running the pip commands though.

    # pip install pyopenssl`enter code here`
    Requirement already satisfied: pyopenssl in /usr/lib64/python3.6/site-packages (18.0.0)
    
    <snipped>
    
    Requirement already satisfied: pycparser in /usr/lib64/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.2.1->pyopenssl) (2.19)
    
    0 讨论(0)
  • 2020-11-29 02:57

    In my case, It was throwing the same error for uninstalling and upgrading. I couldn't uninstall or upgrade.

    AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

    Following worked for me.

    # rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
    # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-16.1.0.dist-info
    # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg
    # pip2.7 install pyopenssl
    Collecting pyopenssl
    Downloading 
    .
    .
    100% |████████████████████████████████| 61kB 5.8MB/s 
    Collecting cryptography>=2.2.1 (from pyopenssl)
    .
    .
    Installing collected packages: cryptography, pyopenssl
    Found existing installation: cryptography 1.7.2
    Uninstalling cryptography-1.7.2:
      Successfully uninstalled cryptography-1.7.2
    Successfully installed cryptography-2.2.2 pyopenssl-18.0.0
    

    WARNING: Try this only if upgrading(sudo pip install pyOpenSSL==16.2.0) or uninstalling(pip uninstall pyopenssl) doesn't help

    0 讨论(0)
  • 2020-11-29 02:59

    I had the same issue and as pip wasn't working anymore I had to do his job manually:

    wget https://files.pythonhosted.org/packages/40/d0/8efd61531f338a89b4efa48fcf1972d870d2b67a7aea9dcf70783c8464dc/pyOpenSSL-19.0.0.tar.gz
    tar -xzvf pyOpenSSL-19.0.0.tar.gz
    cd pyOpenSSL-19.0.0
    sudo python setup.py install
    

    After that everything worked as expected.

    0 讨论(0)
提交回复
热议问题