"Proper way" to manage multiple versions of Python on archlinux "Proper way" to manage multiple versions of Python on archlinux python-3.x python-3.x

"Proper way" to manage multiple versions of Python on archlinux


I would argue you shouldn't create any symlinks like this at all. Especially if you are going to distribute some of your python code, you should not assume a user has python2 or python3 at /usr/bin/python.

If your script requires python2, just use:

#!/usr/bin/env python2

If your script requires python3, use:

#!/usr/bin/env python3

This way your scripts will work fine even through updates to Python. It will also be much more clear what version your script actually needs.


Most unices already have a /usr/bin/python. Overwriting that one is a bad idea, as this is the Python version used by all packages in the system, and changing that one may break them. When installing the Python 2.7 package the executable should be installed as /usr/bin/python2.7 (if not I would claim Archlinux is broken) and it's better to use that when you want to run Python 2.7.

Archlinux is a bit special, since it will use /usr/bin/python for Python 3, despite the default executable name for Python 3 being /usr/bin/python3. This is confusing and can be seen as a bug, but it does mean you can't use that symlink for Python 2, as any other Archlinux script that uses Python 3 will almost certainly break if you do.

So where on other Unices, symlinking /usr/bin/python to Python 2.7 is a bad idea, on Archlinux it is a terrible idea. Instead just install all version you need and call them with /usr/bin/pythonX.X.


There is a nice project on github what helps you with it's called pyenvWhat helps you to manage multiple python instances