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
You can list only packages in the virtualenv by pip freeze --local or pip list --local . This option works irrespective of whether you have global site packages visible in the virtualenv .
If you build with virtualenv --system-site-packages ENV , your virtual environment will inherit packages from /usr/lib/python2. 7/site-packages (or wherever your global site-packages directory is).
You can exit from the virtualenv using exit command, or by pressing Ctrl+d.
virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With