• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Python on CentOS 8 / CentOS 7

Written by Admin, Updated On May 2, 2020
centos, python
How to Install Python on CentOS 8

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 dnf or yum command.

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#

Download the latest release source code from the Python download page using wget command. Currently, the latest Python 3.8 release is 3.8.2.

wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz

Extract the package using below command:

tar xvf Python-3.8.2.tgz

Now, change to the python source directory.

cd Python-3.8*/

Step 3: Install Python 3.8#

Run the configuration script to check all of the dependencies on your system are available:

./configure --enable-optimizations

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:

python3.8 --version

The output should show the Python version:

Python 3.8.2

Pip is also installed, check version by typing:

pip3.8 --version
pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

Conclusion#

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.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Git on Ubuntu 20.04 (Focal Fossa)
Next Article   How to Install Visual Studio Code on Ubuntu 20.04

Related Posts

  • How to Install Python 3.11 on Debian 11

    How to Install Python on Debian 11

    January 25, 2023
  • How to Install Php 8 on CentOS 8

    How to Install PHP 8 on CentOS 8

    January 27, 2021
  • How to Install Python 3.9 on CentOS 8

    How to Install Python 3.9 on CentOS 8

    December 31, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Jenkins on Debian 11
    How to Install Jenkins on Debian 11 January 5, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook