Forums

pip error: AttributeError: 'module' object has no attribute 'HTTPSConnection'

I tried to install a new module in my virtualenv (the module was django-extensions, my virtualenv is Django 1.7 with Python 3.3), and got the following error:

AttributeError: 'module' object has no attribute 'HTTPSConnection'.

Thinking it was just a problem with the module - and possibly related to the recent Trusty upgrade - I decided to rebuild my virtualenv. However, when I tried to use 'pip freeze', I got the same error. I haven't been able to find relevant threads on fixing this problem, any thoughts? Full output below:

(django1_7)04:08 ~/davinci (master)$ pip freeze
Traceback (most recent call last):
File "/home/bjorncooley/.virtualenvs/django1_7/bin/pip", line 9, in <module>
  load_entry_point('pip==1.3.1', 'console_scripts', 'pip')()
File "/home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 343, in load_entry_point
  return get_distribution(dist).load_entry_point(group, name)
File "/home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 2308, in load_entry_point
  return ep.load()
File "/home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 2014, in load
  entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/__init__.py", line 11, in <module>
  from pip.vcs import git, mercurial, subversion, bazaar  # noqa
File "/home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/vcs/mercurial.py", line 9, in <module>
  from pip.download import path_to_url2
File "/home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/download.py", line 72, in <module>
  class VerifiedHTTPSConnection(httplib.HTTPSConnection):
AttributeError: 'module' object has no attribute 'HTTPSConnection'

We have seen that with a few virtualenvs. We're not sure exactly what causes it, but you can work around it by building a package list by listing the contents of /home/bjorncooley/.virtualenvs/django1_7/lib/python3.3/site-packages/. That directory will have a list of all the packages and versions that you installed in the virtualenv. It's not as pretty as the output of pip freeze, but all the information is there.

Ok, that worked. Thanks!