Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save denilsonsa/21e50a357f2d4920091e to your computer and use it in GitHub Desktop.
Save denilsonsa/21e50a357f2d4920091e to your computer and use it in GitHub Desktop.
Python Virtual Environments on Debian and Ubuntu

pyvenv-3.3 (Ubuntu 13.10, also Debian)

Symptoms

pyvenv-3.3 venvdir
venvdir/bin/python -c 'import sys; print(sys.path)'
# This should print the venvdir in sys.path.
# But in buggy Ubuntu/Debian, it doesn't.

Solution

ln -s site-packages venvdir/lib/python3.3/dist-packages

More info

pyvenv-3.4 (Ubuntu 14.04, also Debian)

Symptoms

pyvenv-3.4 venvdir
# Returns an error regarding ensurepip command

Solution

pyvenv-3.4 --without-pip venvdir
source venvdir/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source venvdir/bin/activate

More info

pyvenv-3.4 (Ubuntu 14.04)

Symptoms

pyvenv-3.4
The program 'pyvenv-3.4' is currently not installed. You can install it by typing:
sudo apt-get install python3.4

Solution

Use:

python3 -m venv

Instead of:

pyvenv-3.4

More info

pyvenv-3.4 (Ubuntu 15.04)

Works fine!

Copy link

ghost commented Sep 26, 2014

Crunchbang is quite buggy. However, by using this command, it works well.

virtualenv --python=python3.4 venv

@denilsonsa
Copy link
Author

@LysanderAkili: What is Crunchbang? What are you talking about?

@Veedrac
Copy link

Veedrac commented Sep 26, 2014

CrunchBang is a Linux distribution.

@bendavis78
Copy link

The fix for Ubuntu 14.04 can be shortened to the following:

pyvenv3.4 --without-pip venvdir
curl https://bootstrap.pypa.io/get-pip.py | venvdir/bin/python

No need to activate the virtualenv when using the python binary directly.

@pikeas
Copy link

pikeas commented May 26, 2015

Doesn't work out of the box in 15.04. python3.4 -m venv foo fails with a cryptic error message, and pyvenv/pyvenv-3.4 are not valid commands unless you install python3.4-venv, in which case an old version of pip is installed into the venv.

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