Why is my python programme running correctly in my virtual environment despite not having the packages installed in that environment?
<p>Hi all I hope I can get some help with this. I am on Windows XP, using Python 2.7.12 and command prompt.</p>

<p>I have written a programme balances.py which uses <code>prettytable</code> package. This is installed in my main <code>C:\Python27\Lib\site-packages</code> folder.</p>

<p>I just created a virtual environment:</p>

<pre><code>C:\Environments\virtualenv p1_env 
</code></pre>

<p>and activate the environment:</p>

<pre><code>C:\Environments\p1_env\Scripts\activate
</code></pre>

<p>Now I am in p1_env:</p>

<pre><code>(p1_env)C:\
</code></pre>

<p>and navigate to <code>&lt;p1_env&gt;C:\Python Projects\balances.py</code></p>

<p>and it runs the script even though I have not installed <code>prettytable</code> in <code>p1_env</code></p>

<p><code>pip list</code> for main python installation is </p>

<pre><code>virtualenv, setuptools, pip, prettytable 
</code></pre>

<p>and the <code>pip list</code> for p1_env is </p>

<pre><code>pip, setuptools, wheel
</code></pre>

<p>When i run the script balances.py in <code>p1_env</code> it still runs with <code>prettytable</code>. </p>

<p>My question is why is balances.py running in <code>p1_env</code> even though <code>prettytable</code> is not installed in <code>p1_env</code>? </p>

<p>You have installed prettytables globally. When you create a virtual environment it will include the globally installed packages hence the reason why your program is running. </p>

python virtualenv