• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Python 3.9 on CentOS/RHEL 8

Written by Rahul, Updated on November 30, 2020

Recently, Python development team released latest stable version of Python 3.9. You can download it from its official pages. New version comes with multiple new features and security updates. Python 3.9 uses a new more flexible parser, based on PEG, which replaces LL parser. In the next Python versions the old parser will be deleted.

This tutorial describe you to how to install Python 3.9 on CentOS 8 and RHEL 8 systems. In this tutorial, we will install Python from the source code.

Prerequisites

This Python installation required the GCC compiler on your system. Login to your server using ssh or shell access. Now, use the following command to install prerequisites for Python before installing it.

sudo dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel 

Step 1 – Download Python 3.9

Visit the official download site https://www.python.org/ftp/python to download the latest or required version of the Python.

Command line users can download Python 3.9 via command line:

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

Then, extract the archive file on your system

tar xzf Python-3.9.0.tgz 

This will create a directory named Python-3.9.0 in current directory containing all source files for the Python 3.9.

Step 2 – Install Python on CentOS 8

Change directory to Python-3.9.0. Then prepare the source code with required values before compiling it.

cd Python-3.9.0 
sudo ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions 

Next, compile the source code with make. Here nproc will provide the number of CPU cores available on system. So that make can perform well.

sudo make -j ${nproc} 
sudo make altinstall 
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

Now, we don’t need the downloaded archive file, so delete it to free space.

sudo rm Python-3.9.0.tgz 

Step 3 – Test Python Version

At this step, you have successfully installed Python 3.9 on CentOS/RHEL system. Now, check the installed version’s of Python and PIP.

Check Python Version:

python3.9 -V  

Python 3.9.0

Check PIP Version:

pip3.9 -V  

pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

Step 4 – Create Virtual Environment

Its a good idea to create a separate virtual environment for each Python application. Which provides an isolated environment where Python project have its own modules and set of dependencies.

To create Python virtual environment, run:

sudo /usr/local/bin/python3.9 -m venv /home/rahul/python-app/venv 

All the files will be generated under /home/rahul/python-app/venv directory. You can active the environment by running command:

source /home/rahul/python-app/venv/bin/activate 

Do your stuff with isolated environment here. Once you finish with your work, deactivate the environment by typing:

deactivate 

This will return you back to original system prompt.

Conclusion

This tutorial described you to install Python 3.9 on CentOS 8 and RHEL 8 systems using source code.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy