python virtualenv / global site-packages

python virtualenv / global site-packages

  • Written by
    Walter Doekes
  • Published on

If you’re switching from Ubuntu Oneiric to Ubuntu Precise and you’re using python-virtualenv, you might be in for a surprise:

The default access to the global site-packages modules is reversed between virtualenv 1.6.x and 1.7.

When you were used to finding your apt-get installed python modules like python-mysqldb and python-psycopg2 in your new virtualenv environment, now they’re suddenly unavailable.

The culprit:

       --no-site-packages
           Ignored (the default).  Don´t give access to the global
           site-packages modules to the virtual environment.

That was not the default before.

The new option to get the old behaviour:

       --system-site-packages
           Give access to the global site-packages modules to the
           virtual environment.

By the way, if you already populated your new virtualenv directory with the 1.7 version, you don’t need to recreate it. Removing the no-global-site-packages.txt is enough:

# find /srv/django-env -name no-global-site-packages.txt
/srv/django-env/mysite/lib/python2.7/no-global-site-packages.txt

Back to overview Newer post: sip / digest calculation Older post: mysql / replicating repair table