Python system libraries leak into virtual environment
<p>While working on a new python project and trying to learn my way through virtual environments, I've stumbled twice with the following problem:</p>

<ul>
<li>I create my virtual environment called venv. Running <code>pip freeze</code> shows nothing. </li>
<li>I install my dependencies using pip install dependency. the venv library starts to populate, as confirmed by pip freeze. </li>
<li>After a couple of days, I go back to my project, and after activating the virtual environment via <code>source venv/bin/activate</code>, when running pip freeze I see the whole list of libraries installed in the system python distribution (I'm using Mac Os 10.9.5), instead of the small subset I wanted to keep inside my virtual environment. </li>
</ul>

<p>I'm sure I must be doing something wrong in between, but I have no idea how could this happen. Any ideas? </p>

<hr>

<p>Update:
after looking at <a href="http://stackoverflow.com/a/33366748/3294665">this</a> answer, I realized the that when running <code>pip freeze</code>, the <code>pip</code> command that's being invoked is the one at <code>/usr/local/bin/pip</code> instead of the one inside my virtual environment. So the virtual environment is fine, but I wonder what changes in the path might be causing this, and how to prevent them to happen again (my PYTHONPATH variable is not set).</p>

<p>I realized that my problem arose when moving my virtual environment folder around the system. The fix was to modify the <code>activate</code> and <code>pip</code> scripts located inside the <code>venv/bin</code> folder to point to the new venv location, as suggested by <a href="http://stackoverflow.com/a/16683703/3294665">this</a> answer. Now my pip freeze is showing the right files.</p>

python osx pip virtualenv