Instantly share code, notes, and snippets.

Embed
What would you like to do?
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!

@ghost

This comment has been minimized.

ghost commented Sep 26, 2014

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

virtualenv --python=python3.4 venv

@denilsonsa

This comment has been minimized.

Owner

denilsonsa commented Sep 26, 2014

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

@Veedrac

This comment has been minimized.

Veedrac commented Sep 26, 2014

CrunchBang is a Linux distribution.

@bendavis78

This comment has been minimized.

bendavis78 commented Dec 10, 2014

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

This comment has been minimized.

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