pip install for Python 3 in virtualenv on Mac OSX?
<p>I can <code>pip install</code> and <code>import</code> just about any package on my Mac in a virtual environment, doing the following:</p>

<p>Setting up the virtual environment:</p>

<pre><code>Last login: Mon Oct  3 18:47:06 on ttys000
me-MacBook-Pro-3:~ me$ cd /Users/me/Desktop/
me-MacBook-Pro-3:Desktop me$ virtualenv env
New python executable in /Users/me/Desktop/env/bin/python
Installing setuptools, pip, wheel...done.
me-MacBook-Pro-3:Desktop me$ source env/bin/activate
</code></pre>

<p>Let's <code>pip install</code> pandas:</p>

<pre><code>(env) me-MacBook-Pro-3:Desktop me$ pip install pandas
Collecting pandas
  Using cached pandas-0.19.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting pytz&gt;=2011k (from pandas)
  Using cached pytz-2016.7-py2.py3-none-any.whl
Collecting python-dateutil (from pandas)
  Using cached python_dateutil-2.5.3-py2.py3-none-any.whl
Collecting numpy&gt;=1.7.0 (from pandas)
  Using cached numpy-1.11.1-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting six&gt;=1.5 (from python-dateutil-&gt;pandas)
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: pytz, six, python-dateutil, numpy, pandas
Successfully installed numpy-1.11.1 pandas-0.19.0 python-dateutil-2.5.3 pytz-2016.7 six-1.10.0
</code></pre>

<p>Great! Now, let's see if it works in Python 2.7:</p>

<pre><code>(env) me-MacBook-Pro-3:Desktop me$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import pandas
&gt;&gt;&gt; exit()
</code></pre>

<p><code>pandas</code> loaded in 2.7, now let's try 3.5:</p>

<pre><code>(env) me-MacBook-Pro-3:Desktop me$ python3
Python 3.5.0a4 (v3.5.0a4:413e0e0004f4, Apr 19 2015, 14:19:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import pandas
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ImportError: No module named 'pandas'
&gt;&gt;&gt; 
</code></pre>

<p>:(</p>

<p>I'm running OSX El Capitan 10.11.6. How can I import non-builtin modules in a virtual environment? I really would rather use Python 3...</p>

<p>Try using <code>virtualenv --python=$(which python3) env</code> to create the virtual environment. </p>

<p>When you create a virtualenv by default it uses the python binary it was installed with. So if you did <code>pip install virtualenv</code> on a system where python2.7 was installed first, then virtualenv will use python2.7 by default. You'll want to create separate virtual environments for different python versions.  </p>

python osx pip