Python is a high-level interpreted programming language that supports object-oriented programming and dynamic data types. It is widely used in areas such as web development, scientific computing, and artificial intelligence. CentOS 7 comes with Python 2.7 installed by default, but if you need to use Python 3.8, you can follow the steps below.
Step 1: Install Compilation Environment and Dependencies
Before installing Python, it’s necessary to install some essential compilation tools and dependencies, including GCC, openssl-devel, bzip2-devel, libffi-devel, zlib-devel, and sqlite-devel.
|
|
Step 2: Download and Compile Python 3.8
- Download the source code for Python 3.8. The latest version of 3.8 is 3.8.16. If the download speed from the official website is slow, you can use a download manager and then transfer it to the server.
|
|
- Extract the downloaded tarball.
|
|
- Change into the extracted directory and configure the installation path.
|
|
- Compile and install Python 3.8.
|
|
Alternatively:
|
|
The difference between make altinstall and make install is that make altinstall only installs the executable files and libraries for Python 3.8, avoiding overwriting the existing Python 2.7 executable files and libraries. This prevents any impact on the system’s original Python version and makes it easier to manage multiple versions of Python. If no error messages are displayed, the installation is successful, and you will find the python3 directory under /usr/local/.
Step 3: Add Symbolic Links
|
|
Step 4: Check if Python 3.8 is Installed Successfully
Run the following command to check if Python 3.8 has been installed successfully:
|
|

If you see the version number for Python 3.8 displayed, it means that the installation was successful.
Conclusion
By following the steps above, you can successfully install Python 3.8 on CentOS 7 and use it for development and debugging with the python3.8 command, enabling you to work with Python 3.8 on your CentOS 7 system.