Switching between python2 and python3 as the default python
<p>Is there a standard way to switch between python2 to python3 as the default python, similar to how virtualenv can be used to switch between different sandboxed python environments?</p>

<p>I would like to avoid manually fiddling with symlinks and the PATH variable so that the solution is portable.</p>

<p>Since it is about switching python version, the solution must obviously not be written in python but rather in bash or something portable.</p>

<p>And a slight deviation from the original question: if there was a way to have something like <code>mkvirtualenv2</code> and <code>mkvirtualenv3</code> that would be an ever better solution. Is it possible? I understand it's not, because virtualenv can only operate within a single Python interpreter env. If I install virtualenv for both python2 and python3, then how to switch between executables in a clean way?</p>

<p>Ideally it would be something like <a href="https://github.com/creationix/nvm" rel="nofollow">nvm</a> for nodejs or <a href="http://rbenv.org/" rel="nofollow">rbenv</a> for Ruby.</p>

<p>There is a way, and it is called <a href="http://conda.pydata.org/docs/intro.html" rel="nofollow">Conda</a> (you can install <a href="http://conda.pydata.org/miniconda.html" rel="nofollow">Miniconda</a> to start with).</p>

<p>It lets you create virtual environments in which you can specify the Python interpreter version you want to use. In example:</p>

<pre><code>conda create -n new_environment python=3.5
</code></pre>

<p>Conda will download the interpreter for you, so you don't need to have it available in your system.</p>

<p>Appart from that, you can install packages without needing to compile them (in case they are not fully written in Python), which is something very convenient specially if you are on Windows. So, for example, <code>conda install numpy matplotlib</code> will not require you to compile any of those packages.</p>

python python-3.x virtualenv python-2.x pyenv