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.
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-packagesis the default behaviour on recent versions (>= 1.7) of virtualenv, you just need to recreate the virtualenv with the command:or on older versions where
--system-site-packageswas the default behaviour:replacing
$PATH_TO_VIRTUALENVwith 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.