ImportError: cannot import name HTTPSHandler using PIP

后端 未结 12 1850
刺人心
刺人心 2020-11-28 07:35

Facing an HTTPSHandler error while installing python packages using pip, following is the stack trace,

--------desktop:~$ pip install Django==1.3
Traceback (         


        
相关标签:
12条回答
  • 2020-11-28 07:53

    You need to install the OpenSSL header files before building Python if you need SSL support. On Debian and Ubuntu, they are in a package called libssl-dev. You might need some more dependencies, as noted here.

    0 讨论(0)
  • 2020-11-28 07:54

    I was having this problem on Mac OSX, even after confirming my PATH, etc.

    Did a; pip uninstall virtualenv then install virtualenv and it seemed to works now.

    At the time I had forced brew to link openssl, unlinked it and virtualenv still seems to work but maybe that's because it was originally linked when I reinstalled it.

    0 讨论(0)
  • 2020-11-28 07:54

    On OSX, brew kept refusing to link against its openssl with this error:

    15:27 $ brew link --force openssl
    Warning: Refusing to link: openssl
    Linking keg-only openssl means you may end up linking against the insecure,
    deprecated system OpenSSL while using the headers from Homebrew's openssl.
    Instead, pass the full include/library paths to your compiler e.g.:
      -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
    

    I finally was able to get it working with:

      brew remove openssl
      brew uninstall --force openssl
      brew install openssl
      export LDFLAGS=-L/usr/local/opt/openssl/lib
      export CPPFLAGS=-I/usr/local/opt/openssl/include
      brew remove python
      brew update
      brew install python
    
    0 讨论(0)
  • 2020-11-28 07:56

    It seems your pip requires HTTPSHandler which is part of SSL library.

    OSX

    On OS X you should link OpenSSL during Python installation (See: #14497).

    For Python 2:

    brew reinstall python --with-brewed-openssl
    pip install --upgrade pip
    

    For Python 3:

    brew reinstall python3 --with-brewed-openssl
    pip3 install --upgrade pip
    

    You could have multiple Python instances together, to list them run:

    brew list | grep ^python
    

    Or list your version via ls -al /usr/local/lib/python*.

    0 讨论(0)
  • 2020-11-28 07:57

    I'm using Redhat and have met the same problem.

    My solution is :

    1. install openssl and openssl-devel ---- yum install openssl openssl-devel -y
    2. install krb5-devel ---- yum install krb5-devel
    3. change to your python's directory and recompile it ---- make

    If I didn't do the 2nd step, when I recompiled my python2.7 , the log would say " fail to build module _ssl".

    0 讨论(0)
  • 2020-11-28 08:09

    OSX + homebrew users:

    You can get the latest updates to the recipe:

    brew reinstall python
    

    But if you still get the issue, e.g. maybe you have upgraded your OS, then you may need to get the latest openssl first. You can check which version and where it is used from:

    openssl version -a
    which openssl
    

    To get the latest openssl:

    brew update
    brew install openssl
    brew link --overwrite --dry-run openssl  # safety first.
    brew link openssl --overwrite
    

    This may issue a warning:

    bash-4.3$ brew link --overwrite --dry-run openssl
    Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. 
    Instead, pass the full include/library paths to your compiler e.g.: 
    -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
    

    Side note: this warning means that for other apps, you may want to use

    export LDFLAGS=-L/usr/local/opt/openssl/lib
    export CPPFLAGS=-I/usr/local/opt/openssl/include
    

    Then recompile python:

    brew uninstall python
    brew install python --with-brewed-openssl
    

    or for python 3

    brew uninstall python3
    brew install python3 --with-brewed-openssl
    
    0 讨论(0)
提交回复
热议问题