Reputation: 1823
I have 64-bit Python 2.7.5 installed at C:\Python27
.
My environment variables are as follows:
Path: %PYTHONHOME%\Scripts;
PYTHONHOME: C:\Python27;
PYTHONPATH: C:\Python27\Lib;C:\Python27\Lib\lib-tk;C:\Python27\DLLs;
I created a virtualenv called 'foo', but noticed that pip freeze
after activating foo showed all the packages from my global installation.
After playing around, it seems that removing the PYTHONHOME
variable fixes this; pip freeze
then only sees packages installed in my virtualenv.
However, I currently have to remove PYTHONHOME
manually. There is a blurb in the virtualenv's Scripts\activate
script that should clear it, but doesn't seem to ($env:PYTHONHOME
before and after activating cheerfully show the same PYTHONHOME
):
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "$PYTHONHOME" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
How do I clear PYTHONPATH
automatically? Does the activate script need to be modified in some way under Windows?
Upvotes: 5
Views: 8691
Reputation: 6043
When creating the virtual env you can use the --no-site-packages flag as such:
virtualenv env_name --no-site-packages
Then as is said in the documentation
..[the virtualenv] will not include the packages that are installed globally.
Upvotes: 0