Skip to content

Instantly share code, notes, and snippets.

@fernandojunior
Last active March 26, 2016 00:14
Show Gist options
  • Save fernandojunior/73e089f4de867fc71870 to your computer and use it in GitHub Desktop.
Save fernandojunior/73e089f4de867fc71870 to your computer and use it in GitHub Desktop.
Workaround to fix broken virtualenv (copyreg, psycopg)

virtualenv + python-future = broken virtualenv

For Ubuntu 14.04, this combination worked for me:

$ wget https://bootstrap.pypa.io/get-pip.py -O - | sudo python3.4
  • Replace the old virtualenv (python 2.7 to python 3.4) :
$ sudo pip3.4 install virtualenv
  • Just to check:
$ head -n 1 /usr/local/bin/virtualenv
#!/usr/bin/python3
  • Now, the following commands will run:
$ virtualenv venv34
Using base prefix '/usr'
New python executable in venv34/bin/python3
Also creating executable in venv34/bin/python
Installing setuptools, pip, wheel...done.

$ ./venv34/bin/pip install virtualenv
Collecting virtualenv
  Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.2

$ ./venv34/bin/virtualenv -p python venv
Running virtualenv with interpreter /usr/bin/python
New python executable in venv/bin/python
Installing setuptools, pip, wheel...done.

$ /usr/bin/python --version
Python 2.7.6

$ ./venv/bin/pip install future virtualenv
Collecting future
Collecting virtualenv
  Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: future, virtualenv
Successfully installed future-0.15.2 virtualenv-13.1.2

$ ./venv34/bin/pip install future
Collecting future
Installing collected packages: future
Successfully installed future-0.15.2
  • To avoid compilation errors from Python extensions written in C or C++ (ref):
$ sudo apt-get update
$ sudo apt-get install -y build-essential
$ sudo apt-get install -y python3.4-dev
$ sudo apt-get install -y python3-software-properties

Now, tox runs beautifully :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment