

configure -enable-optimizationsĪnd you can install the Python package with the following command: sudo make altinstallĪnd when finished, you can check the installation: python3.9 -V cd /tmp/Īfter that, decompress it tar xvf Python-3.9.2.tgzĪnd access the generated folder: cd Python-3.9*/īefore installing Python configure the source code.

Now proceed to download it in the /tmp/ folder. If you don’t have it installed run: sudo dnf install wget Now we can download the latest stable version of Python which is 3.9.2 with wget.

Then install the necessary packages to compile packages on CentOS 8 sudo dnf groupinstall "Development Tools".Īnd also other necessary packages such as openssl-devel sudo dnf install openssl-devel bzip2-devel libffi-devel In this post, I will use the sudo command to get root permissions so you need to have it. Then update the system completely: sudo dnf update So, open a terminal or connect to your server via SSH. Install Python 3.9 on CentOS 8īy default, CentOS 8 includes Python but in an older version. Just download your preferred version from let’s go for it. The additional binaries will be in /usr/bin, for example: The exact version may change depending on what version of CentOS you are running. This is the best way to install additional versions of Python since their updates will be maintained automatically. This example is for installing Python 2.7, but you can easily do similar steps for version 3.3, etc. Therefore, if you need a newer version of Python, the only safe way to do this is to install it alongside the system version. If you ran the command above, you’ll see all the packages that depend on Python, most all of which will break (including Yum itself) if you alter the system-installed package or attempt to upgrade. Hit CTRL+C once it prompts to continue, and no changes will be made to your system. Warning, do not pass a ‘-y’ to the above command. If you’re feeling brave, try this to see why:

Contrary to what the title of this post implies, you actually cannot safely upgrade Python on any Redhat distribution. Currently, the version packaged for CentOS 5 and 6 is 2.6. If you’re running CentOS, you’re probably a few versions behind on Python.
