Calum
Calum

Reputation: 2130

how to isolate virtualenv from local dist-packages?

How do you stop virtualenv using '/usr/local/lib/python2.7/dist-packages'?

currently it when i run

virtualenv --no-site-packages ENV

it still uses the dist-packages that i wish to stop

EDIT: /usr/local/lib/python2.7/dist-packages is in the PYTHONPATH, it needs to be there for other apps

Upvotes: 6

Views: 5758

Answers (1)

bikeshedder
bikeshedder

Reputation: 7487

Your edit explains the behaviour you are observing.

You need to unset PYTHONPATH when activating the virtualenv.

unset PYTHONPATH
source /path/to/virtualenv/bin/activate

virtualenv --no-site-packages ENV creates an empty virtualenv just fine, but your PYTHONPATH export nullifies your empty virtualenv.

In order to make things simpler you can just edit the activate script and add the unset PYTHONPATH command there. If you want to restore the original PYTHONPATH upon deactivating the virtualenv you also need to modify the deactivate function in that file.

Upvotes: 9

Related Questions