Multiple Python versions on Linux

Linux comes with Python bundled, but if it often lags recent developments. If you need a specific version of Python you can download it from python.org and install on your box. You can take .xz archive, it is slightly smaller and tar available on you linux box should handle it.

# change to a suitable directory and unpack python
tar xf ~/Downloads/Python-3.8.0.tar.xz 
./configure --prefix $HOME/.local    # any directory you can write to is fine
make
make test
make install
# make sure $HOME/.local/bin is on your $PATH
# python versions come with a nice naming convention
python3.8    # invokes python 3.8 interpreter you have installed
pip3.8       # installs packages for your version
# now you can create a virtual environment for your development
python3.8 -m venv project_directory

You don’t need to install python with sudo if you need it for private use. System rights are only needed if you want the software available for other users. If a software can run without system rights it should be run without them.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.