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

后端 未结 20 1478
無奈伤痛
無奈伤痛 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:40

    Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .

    I did:

    pip uninstall pyopenssl
    

    and then

    pip install pyopenssl
    

    ...and my Python script worked again!

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

    Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.

    sudo python -m easy_install --upgrade pyOpenSSL
    

    credit @delimiter (Answer)

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

    Try with the following commands:

    easy_install -U pip
    easy_install -U pyOpenSSL
    
    0 讨论(0)
  • 2020-11-29 02:45

    Just in case anyone else isn't finding exactly the right incantations to make this work, as of Nov 2018 the thing that worked for me was:

    sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/ sudo apt install --reinstall python-openssl

    Good luck!

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

    Try with:

    export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
    sudo apt-get install --reinstall python-openssl
    
    0 讨论(0)
  • 2020-11-29 02:49

    I just encountered this on my Ubuntu 16.04 host. There appears to be a version conflict between the apt repo packages for python-openssl and python-crypotgraphy, vs what someone installed manually with pip into /usr/local/python2.7/dist-packages.

    Once it got into this state, the system standard pip couldn't execute, either. I got around the chicken-and-egg problem by manually setting a PYTHONPATH environment variable that excluded the /usr/local part of the tree thusly:

        $ export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
        $ /usr/bin/pip uninstall cryptography
        $ unset PYTHONPATH
    

    I acquired the above list of library directories to use with the python shell:

        import sys
        for p in sys.path:
           print(p)
    

    and then copying everything listed except the one /usr/local directory. Your system may have a different list in its path. Adjust accordingly.

    I also had some manual apt-get install --reinstall python-openssl python-cryptography commands scattered in my bash history, which may or may not have been necessary.

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