

HINT – To get the number of cpu cores of your Linux CentOS box, use these Bash commands grep 'cpu cores' /proc/cpuinfo or nproc. The command make -j `nproc` will ensure using of all fo your CPU cores and will decrease a compile-time and the command make altinstall is critical because of preserving the default shipped Python binary /usr/bin/python. For better performance we are going to use a switch -enable-optimizations for enabling PGO (profile guided optimisation) and so yielding an extra speed boost of Python binaries around 5-10%.

Of course, you can choose a folder according to your needs. We are going to use the switch -prefix=/opt/python310 to set the root directory for all Python binaries and libraries. Step 3 – compile Python source code into binariesĪt the moment we have everything ready for compiling the actual Python source code. To do that perform this set of bash commands. We download the a source code of latest Python from the official Python page and extract Python-3.10.0.tgz to the /tmp directory. Step 2 – download and unpack Python source code sudo yum -y install wget yum-utils gcc openssl-devel bzip2-devel libffi-devel

I chose the minimal amount of packages those are included in CentOS as well. You also need some necessary libraries and developer tools to allow you to build and compile software from source code. Let’s update your CentOS with the yum command. It is a good idea to have up-to-date OS system before you start doing anything else. Step 1 – prepare CentOS for Python compilation You will need functional Linux CentOS 7 or 8 machine, an access to the root account and of course an internet connection.Īll the steps you can perform as an non-root user but with a support of the sudo command. COPY & PASTE cheatsheet – for installing latest Python 3.10, 3.9, 3.8 or 3.7 on Linux CentOS 7, 8
