After upgrading my Debian Sid to Python 2.7.9 suddenly some packages stopped working in my virtualenv. The issue is related to the new behavior of urllib2 and ssl modules. Basically they now behave as designed: strictly checking the certificates validation. Well, this will stop half of the Internet, but sooner or later a workaround will be found to avoid this.

In the meantime I’ve tried to downgrade system wide python to 2.7.8 but it breaks a lot of other packages, so I scribbled down this procedure that will work in virtualenv. It consists in compiling python 2.7.8 from source and then install it into a virtualenv with some caveats.

Requirements

  • libssl-dev, build-essentials, virtualenvwrapper (optional) packages.

The libssl-dev package must be installed before Python compilation to allow the ssl support in the next easy_install (and pip) steps, besides the actual ssl support into Python…

Compilation

  • wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
  • tar xvzf Python-2.7.8.tgz
  • cd Python-2.7.8
  • mkdir /your/path/for/python/
  • ./configure --prefix=/your/path/for/python/
  • make
  • make install

I installed python in a subfolder (like opt/) in my HOME, change it as you like.

Install easy_install and pip

  • export PATH=/your/path/for/python/bin:$PATH
  • check that the version used is 2.7.8 with python --version
  • wget https://pypi.python.org/packages/source/s/setuptools/setuptools-15.0.tar.gz#md5=2a6b2901b6c265d682139345849cbf03
  • tar xvzf setuptools-15.0.tar.gz
  • cd setuptools-15.0
  • python setup.py install
  • Check the easy_install used is the one into your custom folder using which easy_install
  • easy_install pip
  • which pip

Virtualenv

I use virtualenvwrapper because I’m very comfortable with.

  • pip install virtualenv
  • mkvirtualenv --python /path/for/your/python/bin/python myvirtualenv

Now the python version used should be the 2.7.8 only inside the myvirtualenv virtualenv. When you need it just workon myvirtualenv and install all the modules you want with pip

You can delete the compilation folder for python but be sure to leave the custom python executable folders (/your/path/for/python).