Webfaction, Virtualenv and no-site-packages

Back in the day, if you wanted your virtualenv to not contain global packages, you needed to add the flag –no-site-packages when using the mkvirtualenv command. Now that is the default. That flag is no longer used. This can be somewhat confusing if you read older documents.

Easy enough. Except on Webfaction, you still get the python packages that you installed outside of the virtualenv. There is some mojo to exclude those packages, but it is not easy to find on Google. So here it is:

mkvirtualenv foo
deactivate
touch $WORKON_HOME/foo/lib/$PYTHON/sitecustomize.py
workon foo

In other words, create the empty file sitecustomize.py.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s