1

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?

1 Answers1

0

Try this to create your virtualenv:

#! /bin/bash
#
# Create a Python virtualenv using current code (not the distribution's outdated one)
#
PYTHON=/usr/bin/python2
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
    PYTHON="$1"
    shift
fi

# Be nice to github (get current source only once per day)
venv_cached=/tmp/$USER-virtualenv-$(date +'%Y-%m-%d').py
venv='https://github.com/pypa/virtualenv/raw/master/virtualenv.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 "$@"
pyroscope
  • 231
  • 1
  • 3