cannot load Python 3.5 interpreter for virtualenv
<p>I have installed Python 3.5 through Anaconda on the OSX system. After installing and activating the virtual environment, </p>

<pre><code>virtualenv venv
source venv/bin/activate
</code></pre>

<p>The Python version is Python 2.7.10. And while we are allowed to load the interpreter of our choice in <a href="http://docs.python-guide.org/en/latest/dev/virtualenvs/" rel="nofollow">virtualenv</a>, "/usr/bin/" only has folders for Python 2.6 and 2.7. After finding out the Anaconda python 3.5 path (   /Users/Username/anaconda/lib/python3.5)
and trying to load it,</p>

<blockquote>
  <p>for: virtualenv -p /Users/Username/anaconda/lib/python3.5 venv</p>
</blockquote>

<p>the code returns a [Errno 13] Permission Denied</p>

<pre><code>&gt; Running virtualenv with interpreter /Users/Username/anaconda/lib/python3.5
&gt; Traceback (most recent call last):   File "/usr/local/bin/virtualenv",
&gt; line 11, in &lt;module&gt;
&gt;     sys.exit(main())   File "/Library/Python/2.7/site-packages/virtualenv.py", line 790, in main
&gt;     popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env)   File
&gt; "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
&gt; line 710, in __init__
&gt;     errread, errwrite)   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
&gt; line 1335, in _execute_child
&gt;     raise child_exception
OSError: [Errno 13] Permission denied
</code></pre>

<blockquote>
  <p>for: virtualenv -p /Users/Username/anaconda/bin/python3.5 venv</p>
</blockquote>

<p>there seems to be another type of error...</p>

<pre><code>Running virtualenv with interpreter /Users/Username/anaconda/bin/python3.5
Using base prefix '/Users/Username/anaconda'
New python executable in venv/bin/python3.5
Not overwriting existing python script venv/bin/python (you must use venv/bin/python3.5)
ERROR: The executable venv/bin/python3.5 is not functioning
ERROR: It thinks sys.prefix is '/Users/Username/.../targetfolder' (should be '/Users/Username/.../targetfolder/venv')
ERROR: virtualenv is not compatible with this system or executable
</code></pre>

<pre><code>ERROR: The executable venv/bin/python3.5 is not functioning
ERROR: It thinks sys.prefix is '/Users/Username/.../targetfolder' (should be '/Users/Username/.../targetfolder/venv')
ERROR: virtualenv is not compatible with this system or executable
</code></pre>

<p>This error results from trying to combine incompatible versions of Python and the virtualenv tool.  I'm not sure precisely where the incompatibility comes from, but I do know how to work around it.</p>

<p>Assuming your Python is reasonably functional and recent (read: 3.3 or later), this should always work:</p>

<pre><code>/path/to/python3.5 -m venv venv
</code></pre>

<p>The first venv is the <a href="https://docs.python.org/3/library/venv.html" rel="nofollow">venv module</a>.  The second is the name of the directory where you want to create a virtualenv.  This command asks Python to create a virtualenv itself, rather than shelling out to a third-party tool.  Thus, we can be reasonably confident Python will do it correctly, and in particular that it will not be incompatible with itself.</p>

<hr>

<p>Unfortunately, the version of Python installed with Anaconda cannot be described as "reasonably functional" because <a href="http://stackoverflow.com/questions/38524856/anaconda-3-for-linux-has-no-ensurepip">it lacks <code>ensurepip</code></a>.  That makes it impossible for the venv module to bootstrap <code>pip</code> into your virtualenv.  So you will need to build your venv without pip, and then install it manually:</p>

<pre><code>/path/to/python3.5 -m venv --without-pip venv
</code></pre>

<p>Then download and run <a href="https://pip.pypa.io/en/stable/installing/" rel="nofollow"><code>get-pip.py</code></a> from within the virtualenv.</p>

python python-2.7 python-3.x virtualenv