Python is the popular high-level programming language, which is universal, fast and used in many projects, including large ones.
Installing the fresh variant of the libraries for supporting Python language in CentOS operating system is not difficult, especially if you follow everything in stages. In this tutorial, we will build version 3.10.11 from sources.
Updating Operating System Packages
Before updating Python directly, we update the operating system. Navigate terminal then execute:
Installing Python on CentOS
To work with Python you need to install it on your computer, which can be a non-trivial task for Linux newbies. At this point, we'll walk via the installation step by step and provide detailed tutorial with commands and descriptions of each step.
Installing additional packages
If your system does not have the "wget" module, execute the commands one after the other:
For further work, you need to get packages:
After successfully completing the installation, let's install the "Development Tools"
To continue, you must go to the directory:
Loading source files
We get the latest version from the Python.org website. Visiting it, under "Downloads\Source code" copy the download link we found and need. Then run in the terminal, pasting in the just copied link:
After downloading, you must retrieve the contents of the archive. You can use this command to do so:
Navigate to the resulting Python-3.11.3 folder and install directly from the source code:
Complete the installation by executing the commands one after the other:
Make sure the update is successful by sending a line to the terminal:
If version 3.11.x of Python is displayed, then all previous steps have gone correctly! It is now possible to use the universal programming language for your own purposes.
Python version update
If you already have an earlier version of Python, follow the steps below.
Installing additional Python packages
In order to perform a Python version upgrade, a few new packages must be supplied in addition. Send commands to the terminal:
Loading source files
We get the latest version from the Python.org website. Visiting it, under "Downloads\Source code" copy the download link we found and need. Then run in the terminal, pasting in the just copied link:
After downloading, you must retrieve the contents of the archive. You can use this command to do so:
Update version
Navigate to the resulting Python-3.11.3 folder and install directly from the source code:
Check update
Make sure the update is successful by running the command:
If Python version 3.11.x is displayed then the update was successful.
Summary
In this review, we looked at "How to update Python on CentOS" by using source code files.
You may be interested in the following materials on the subject
FAQ: Installing and Upgrading Python on CentOS
- Q: Why should I upgrade to the latest version of Python on CentOS?
A: The latest Python releases bring important security patches, performance improvements, and new features that older versions lack. Upgrading ensures your applications run securely and efficiently. - Q: Can I install multiple Python versions on CentOS?
A: Yes. You can compile a new version from source and keep it alongside the system default Python without breaking dependencies. Just make sure to call the correct version (e.g., python3.11). - Q: What if I already have Python installed—should I remove the old version first?
A: No. CentOS relies on Python for system tools, so do not remove the default version. Instead, install the latest version in parallel. - Q: What packages are required before compiling Python from source?
A: You’ll need development tools and libraries such as gcc, zlib-devel, openssl-devel, readline-devel, libffi-devel, and others to ensure a successful build. - Q: How do I verify that Python was installed or upgraded correctly?
A: Run the command python3 --version. If it shows the expected Python 3.11.x release (or higher), the installation/upgrade was successful.