Facing an HTTPSHandler error while installing python packages using pip, following is the stack trace,
--------desktop:~$ pip install Django==1.3
Traceback (most recent call last):
File "/home/env/.genv/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/home/env/.genv/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/env/.genv/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/home/env/.genv/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/env/.genv/lib/python2.7/site-packages/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/home/env/.genv/lib/python2.7/site-packages/pip/util.py", line 17, in <module>
from pip.vendor.distlib import version
File "/home/env/.genv/lib/python2.7/site-packages/pip/vendor/distlib/version.py", line 13, in <module>
from .compat import string_types
File "/home/env/.genv/lib/python2.7/site-packages/pip/vendor/distlib/compat.py", line 31, in <module>
from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler
I used to edit Modules/setup.dist file and uncomment SSL code lines and rebuilt it, with reference to following thread : http://forums.opensuse.org/english/get-technical-help-here/applications/488962-opensuse-python-openssl-2.html
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.
On OSX, brew kept refusing to link against its openssl with this error:
I finally was able to get it working with:
You need to install OpenSSl before make and install Python to solve the problem.
On Centos:
source
For Ubuntu
First check wheather install openssl-develop
Try another way to reinstall
pip
use
setuptools
to install pip rather than install with source code may can solve the problem of dependency.It seems your
pip
requiresHTTPSHandler
which is part ofSSL
library.OSX
On OS X you should link OpenSSL during Python installation (See: #14497).
For Python 2:
For Python 3:
You could have multiple Python instances together, to list them run:
Or list your version via
ls -al /usr/local/lib/python*
.Another symptom of this problem for me was if I went into the python console of my virtualenv and did
import ssl
it would error out. Turns out my virtualenv wasn't using thebrew
version of python, just the default install on my machine. No clue why the default install suddenly stopped working, but here's how I fixed it the problem:rmvirtualenv myvirtualenv
brew update
brew reinstall python
mkvirtualenv -p /usr/local/Cellar/python/whatever_version_number/bin/python myvirtualenv