Is it possible to set --no-site-packages in virtualenv after it's already set up?
python, virtualenv
Solution
See also for the inverse: Modifying a virtualenv.
For completeness I'll post the inverse instructions of my answer there. Eventually this question can be merged with the other one.
Since `--no-site-packages` is the default behaviour on recent versions (>= 1.7) of virtualenv, you just need to recreate the virtualenv with the command:
$ virtualenv $PATH_TO_VIRTUALENV
or on older versions where `--system-site-packages` was the default behaviour:
$ virtualenv --no-site-packages $PATH_TO_VIRTUALENV
replacing `$PATH_TO_VIRTUALENV` with the path to the existing virtualenv. This will reinstall the virtualenv, reconfiguring it to prevent access to global packages, while keeping the packages already installed there.
Problem
Possible Duplicate: Can I change an an existing virtualenv to ignore global site packages? (like --no-site-package on a new one) I have a virtualenv set up, with plenty of packages installed that I don't want to reinstall. Is there a way to set up this existing virtualenv so that it does not use the global site-packages directory? FYI, this is primarily motivated by getting this warning: `UserWarning: Module X was already imported from` every time I start up, e.g., mercurial. Related, but doing the inverse: Revert the `--no-site-packages` option with virtualenv. This implies that all I need is a `lib/no-global-site-packages.txt` file, but an empty one of those seems to have no effect.
Related problems
- Revert the `--no-site-packages` option with virtualenv
- Modifying a virtualenv so that packages installed in global site-packages are available
- Can I change an an existing virtualenv to ignore global site packages? (like --no-site-package on a new one)
- Can I change an an existing virtualenv to ignore global site packages? (like --no-site-package on a new one)