title: How can I unset PYTHONHOME when activating a virtualenv in Windows?
body: <p>I have 64-bit Python 2.7.5 installed at <code>C:\Python27</code>.</p>
  
  <p>My environment variables are as follows:</p>
  
  <pre><code>Path: %PYTHONHOME%\Scripts;
  PYTHONHOME: C:\Python27;
  PYTHONPATH: C:\Python27\Lib;C:\Python27\Lib\lib-tk;C:\Python27\DLLs;
  </code></pre>
  
  <p>I created a virtualenv called 'foo', but noticed that <code>pip freeze</code> after activating foo showed all the packages from my global installation.</p>
  
  <p>After playing around, it seems that removing the <code>PYTHONHOME</code> variable fixes this; <code>pip freeze</code> then only sees packages installed in my virtualenv.</p>
  
  <p>However, I currently have to remove <code>PYTHONHOME</code> manually.  There is a blurb in the virtualenv's <code>Scripts\activate</code> script that should clear it, but doesn't seem to (<code>$env:PYTHONHOME</code> before and after activating cheerfully show the same <code>PYTHONHOME</code>):</p>
  
  <pre><code># 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
  </code></pre>
  
  <p>How do I clear <code>PYTHONPATH</code> automatically?  Does the activate script need to be modified in some way under Windows?</p>
  
  <p>Thanks!</p>