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><a href="https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux" rel="nofollow">This</a> shows us how to use <code>update-alternatives</code> and/or use an alias in <code>~./bashrc</code>: <code>alias python=/usr/local/bin/python2.7</code></p>

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