Python is popular programming and versatile programming language. It used to write small scripts, build games, develop websites, create machine learning algorithms, analyze data and more. In this tutorial, we will show you how to install python on CentOS 8 system.
Install Python 3.8 on CentOS 8
By default, Python 3.6 is included on CentOS 8. Currently, at the time of writting this article, Python 3.8 is the latest major release of Python. This release includes many new features such as positional-only parameters, assignment expressions, runtime audit hooks, vectorcall, and more. Python 3.8 is not available in the standard CentOS 8 repositories. On CentOS, you can install packages either with
Step 1: Install Python Dependencies
At first, we need to install necessary packages to build Python from the source code on CentOS 8. Run the following commands as root or user with sudo privileges.
sudo yum groupinstall 'development tools'
sudo yum -y install openssl-devel bzip2-devel libffi-devel
Ensure that gcc is available using gcc –version command:
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Step 2: Download latest Python 3.8
Extract the package using below command:
tar xvf Python-3.8.2.tgz
Now, change to the python source directory.
Step 3: Install Python 3.8
configuration script to check all of the dependencies on your system are available:
Initiate compilation of Python 3.8 on CentOS 7.
sudo make altinstall
It will show output as below:
/tmp/tmp9ly9eo2d/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? /tmp/tmp9ly9eo2d/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? Looking in links: /tmp/tmp9ly9eo2d Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-19.2.3 setuptools-41.2.0
Note : Do not use the standard
make install otherwise it will overwrite the default system python binary.
That’s it. Python 3.8 has been installed on your CentOS system, and you can start using it.
Step 4 – Verify Installation
Verify the installation by checking version:
The output should show the Python version:
Pip is also installed, check version by typing:
pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
You successfully learned how to install Python 3.8 on your CentOS 7/ 8 system.
If you have any questions or feedback, feel free to comment below.