Skip to content

Installing Python

To get the latest version you can visiting the official Python web site:

https://www.python.org/downloads/.

Then download and extract the Python archive via the command line:

mkdir ~/Python && cd ~/Python
wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz
tar -xvf Python-3.11.9.tar.xz

Changing into the Python directory ready to compile:

cd Python-3.11.9

If you experience issues with sudo with a message such as user is not in the sudoers file, as root you need to add your user to the sudo group, for example:

useradd -aG sudo richard

Install the following packages needed for compiling Python:

sudo apt install build-essential
sudo dnf install dnf-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel sqlite-devel

Next run the configuration script to prepare your system for the source compilation:

sudo ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions --enable-optimizations

Now start the build process, the-jflag exploits multicore processors for fast build times.

make -j $(nproc)

Finally install Python along side existing version using altinstall and avoid overwriting existing Python3 binaries.

sudo make altinstall

All being well, you should now have two versions Python available, the default system version:

python3 -V
Python 3.12.3

And the one you just installed:

python3.11 -V
Python 3.11.5