0

I am trying to create a virtualenv in which I will run an older version of Django (1.4.2) and a specific version of Python (2.7.8) on OSX El Capitan. Here are the steps I went through:

I downloaded and compiled Python 2.7.8 using this workflow: Is it possible to install another version of Python to Virtualenv?

When I try to create a new virtualenv with --python flag pointed to my newly compiled Python2.7.8, I get an error message that looks like this:

  Complete output from command /Users/luka/xxx/virtu...y2_7_8/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/__init__.py", line 15, in <module>
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/vcs/subversion.py", line 9, in <module>
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/index.py", line 30, in <module>
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/wheel.py", line 35, in <module>
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 14, in <module>
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/_vendor/distlib/compat.py", line 31, in <module>
ImportError: cannot import name HTTPSHandler

If I rerun the same command with --no-setuptools flag, everything works properly, I get access to the Python version I need, but I don't have pip and setuptools in the site-package directory, which is a problem because now I can't install a specific version of Django inside my virtualenv. Can I simply copy existing system-wide pip installation into my virtualenv or install pip in some other way inside of it?

Thanks! Luka

Community
  • 1
  • 1
Lukich
  • 686
  • 1
  • 10
  • 20

1 Answers1

1

You can just install pip in the new virtualenv using the get-pip.py script:

  1. Download get-pip.py, e.g. using wget or curl
  2. Run it with the virtualenv's python, i.e. activate the virtualenv and then run python get-pip.py
taleinat
  • 8,441
  • 1
  • 30
  • 44