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

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

提交回复
热议问题