Python can't find packages in Virtual Environment
<p>I'm trying to setup my environment for a project but python isn't able to find the modules I've installed with pip.</p>

<p>I did the following:</p>

<pre><code>mkdir helloTwitter
cd helloTwitter
virtualenv myenv
Installing setuptools, pip, wheel...done.
source myenv/bin/activate

pip install tweepy
Collecting tweepy
  Using cached tweepy-3.5.0-py2.py3-none-any.whl
Collecting six&gt;=1.7.3 (from tweepy)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting requests&gt;=2.4.3 (from tweepy)
  Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting requests-oauthlib&gt;=0.4.1 (from tweepy)
  Using cached requests_oauthlib-0.6.2-py2.py3-none-any.whl
Collecting oauthlib&gt;=0.6.2 (from requests-oauthlib&gt;=0.4.1-&gt;tweepy)
Installing collected packages: six, requests, oauthlib, requests-oauthlib, tweepy
Successfully installed oauthlib-2.0.0 requests-2.11.1 requests-oauthlib-0.6.2 six-1.10.0 tweepy-3.5.0
</code></pre>

<p>When I try to import the module it says it cannot be found.</p>

<p>The first entry in $PATH is <code>helloTwitter/myenv/bin</code>
All the packages are showing up in the environments site-packages directory.
I seem to be using the right python and pip.
Which python outputs <code>helloTwitter/myenv/bin/python</code>
Which pip outputs <code>helloTwitter/myenv/bin/pip</code></p>

<p>Any advice on where I'm going wrong?</p>

<p>Ok, I think I found a solution, if not an answer.
1. I uninstalled the package and made sure it was not in system or user
2. I re-created the virtual environment. 
3. I checked that the environments python and pip were being used. 
4. This time when installing my package I added the <code>--no-cache-dir</code> option.
The packages install successfully.
Now Python can find the package.</p>

<pre><code>derptop:environmentScience Marcus$ python
&gt;&gt;&gt; from tweepy import StreamListener
&gt;&gt;&gt; StreamListener
&lt;class 'tweepy.streaming.StreamListener'&gt;
</code></pre>

<p>I checked the <code>sys.path</code> and it now includes the <code>site-packages</code> directory from the virtual environment, where previously it was absent.</p>

<p>Output of <code>sys.path</code></p>

<pre><code>['', ....'/Users/Marcus/CodeProjects/environmentScience/myenv/lib/python2.7/site-packages']
</code></pre>

<p>As far as I can tell the <code>sys.path</code> was referencing the wrong site packages directory. Though I'm not sure why. I'm wondering if pips use of the cache was causing the site-packages reference to reset to system.</p>

python virtualenv