Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using virtualenv on Ubuntu 12 and when I install packages with pip (after activating the virtualenv) the packages are not being installed in the environment's site-packages directory, they're ending up in the server's dist-packages directory. When setting up the venv I added the --no-site-packages.

I think this is an issue with Ubuntu using dist-packages instead of site-packages, but how can I get virtual environments working?

share|improve this question
Make sure pip is actually installed into the venv, or use "./bin/pip" instead of simply "pip". – pyroscope Jun 13 '12 at 19:59
If pip is already installed on the system before the venv is created, how can I force install pip into the venv if it already exists and can be found on the system outside the venv? – Michael Waterfall Jun 14 '12 at 13:07
./bin/easy_install -U pip – pyroscope Jun 14 '12 at 18:14

Try this to create your virtualenv:

#! /bin/bash
# Create a Python virtualenv using current code (not the distribution's outdated one)
test -x $PYTHON || PYTHON=/usr/bin/python

# You can provide an alternative Python executable as the first argument, this
# can for example be an interpreter installed into ~/.pythonbrew
if test -x "$1"; then

# Be nice to github (get current source only once per day)
venv_cached=/tmp/$USER-virtualenv-$(date +'%Y-%m-%d').py
test -f $venv_cached || \
    $PYTHON -c "import urllib2; open('$venv_cached','w').write(urllib2.urlopen('$venv').read())"

# Call virtualenv
deactivate 2>/dev/null || true
$PYTHON $venv_cached "$@"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.