How to install Python 3.8 on CentOS 8

Python is one of the most widely used programming languages in the world. The syntax is simple and easy to learn, and Python is a popular choice for beginners and those with work experience. Python is a versatile programming language. It can be used to build various applications, from simple scripts to complex machine learning algorithms.

CentOS 8 includes Python 3.6. You can install or upgrade Python to this version through the dnf tool.

At the time of writing, Python 3.8 is the latest major release of the Python language. It contains many new features, including assignment expressions, positional-only parameters, f-strings support, etc. Python 3.8 is not available in the standard CentOS 8 software source.

This guide explains how to build Python 3.8 from source on CentOS 8. We will also show you how to create a virtual environment.

1. Install Python 3.8 on CentOS 8

Compiling Python from source code requires a C/C++ compiler and other development software packages. The first thing is to install the necessary packages on CentOS 8 to build Python from source code. To do this, run the following command as root or another user with sudo privileges:

sudo dnf groupinstall 'development tools'
sudo dnf install bzip2-devel expat-devel gdbm-devel \
 ncurses-devel openssl-devel readline-devel \
 sqlite-devel tk-devel xz-devel zlib-devel wget

Use wget to download the latest source code from Python download page. Now, the latest version number of Python 3.8 is: 3.8.1. If there is a newer version for download, modify the VERSION variable in the following command line:

VERSION=3.8.1
wget https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz

When the download is complete, unzip the compressed package:

tar -xf Python-${VERSION}.tgz

Switch to the Python source directory and run the configure script. It will perform a series of tests on your current system to ensure that all dependencies have been met:

cd Python-${VERSION}./configure --enable-optimizations

- - The enable-optimizations option optimizes Python binaries by running multiple tests. This will make the build process slower.

Start the build of Python 3.8 by running the following command:

make -j 4

Modify this -j parameter according to your processor core number. You can find your processor core count by running nproc.

Once the build process is over, install the Python binaries:

sudo make altinstall

Please do not use the standard make install, because it will overwrite the default system Python binary package.

that's it. Python 3.8 has been installed on your CentOS system, and you can start using it. Enter the following command to verify:

python3.8--version

The output will show the version number of Python:

Python 3.8.1

Second, create a virtual environment##

The Python virtual environment is a self-contained directory tree that contains a Python installation and a series of additional packages. It allows you to install Python modules in a separate location in the specified project instead of installing it globally. In this way, you don't have to worry about affecting other Python projects.

In this example, we will create a new Python 3.8 project named my_app in the user's home directory.

First, create the project directory and switch to it:

mkdir ~/my_app && cd ~/my_app

Run the following command in the project root directory to create a virtual environment named my_app_venv:

python3.8-m venv my_app_venv

Activate this environment:

source my_app_venv/bin/activate

Once activated, the script prompt will add the name of the environment as a prefix. Starting with Python 3.4, when creating a virtual environment, pip and Python's package manager will be installed by default.

In a virtual environment, you can use pip instead of pip 3.8 and python instead of python3.8:

python -v
Python 3.8.1

Once you have done all the work, you can deactivate this environment. Type deactivate and you will return to your normal shell.

deactivate

Three, summary##

We have shown you how to install Python 3.8 on a CentOS 8 machine and create a virtual environment.

Now you can start developing your Python3 project

Recommended Posts

How to install Python 3.8 on CentOS 8
How to install Python on CentOS 8
R&D: How To Install Python 3 on CentOS 7
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Python 3.8 on Ubuntu 18.04
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
How to install GCC compiler on CentOS 7
How to install Python2 on Ubuntu20.04 ubuntu/focal64
How to install offline JDK1.8 on centos7.0
How to install and configure Elasticsearch on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7
How to install RPM packages on CentOS Linux
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Redis on CentOS 8
How to install Node.js and npm on CentOS 8
[Practice] How to install python3.6 on Ubuntu system
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and configure phpMyAdmin on CentOS 6
How to install and use Curl on CentOS 8
How to install and configure Owncloud on CentOS 8
How to install VirtualBox client extension on CentOS 8
How to install Docker CE on RHEL 8 / CentOS 8
How to install and uninstall tomcat on centos
How to install and configure Redmine on CentOS 8