How to build Python 3.8 on CentOS 7

You can choose any version you want here

Example: Python 3.8.6
Source code:

Step 1: install requirements

yum -y update
yum -y groupinstall "Development Tools"
yum -y install openssl-devel bzip2-devel libffi-devel
yum -y install wget

Step 2:
Download source code

cd /usr/local/src/


[root@s126368 src]# wget
--2020-10-30 10:03:20--
Resolving (, 2a04:4e42:52::223
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24377280 (23M) [application/octet-stream]
Saving to: ‘Python-3.8.6.tgz’

100%[======================================>] 24,377,280  10.8MB/s   in 2.2s

2020-10-30 10:03:23 (10.8 MB/s) - ‘Python-3.8.6.tgz’ saved [24377280/24377280]

Step 3:
Extract tgz file

tar xvf Python-3.8.6.tgz

Step 4:
Change directory

cd Python-3.8*/

Step 5:

./configure --enable-optimizations


checking for glibc _FORTIFY_SOURCE/memmove bug... no
checking for gcc ipa-pure-const bug... no
checking for stdatomic.h... no
checking for GCC >= 4.7 __atomic builtins... yes
checking for ensurepip... upgrade
checking if the dirent structure of a d_type field... yes
checking for the Linux getrandom() syscall... yes
checking for the getrandom() function... no
checking for library containing shm_open... -lrt
checking for sys/mman.h... (cached) yes
checking for shm_open... yes
checking for shm_unlink... yes
checking for pkg-config... /usr/bin/pkg-config
checking whether compiling and linking against OpenSSL works... yes
checking for X509_VERIFY_PARAM_set1_host in libssl... yes
checking for --with-ssl-default-suites... python
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile

Step 6:

make altinstall


running install_scripts
copying build/scripts-3.8/pydoc3.8 -> /usr/local/bin
copying build/scripts-3.8/2to3-3.8 -> /usr/local/bin
copying build/scripts-3.8/idle3.8 -> /usr/local/bin
changing mode of /usr/local/bin/pydoc3.8 to 755
changing mode of /usr/local/bin/2to3-3.8 to 755
changing mode of /usr/local/bin/idle3.8 to 755
rm /usr/local/lib/python3.8/lib-dynload/
rm -r /usr/local/lib/python3.8/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/ \
if test "xupgrade" != "xno"  ; then \
        case upgrade in \
                upgrade) ensurepip="--altinstall --upgrade" ;; \
                install|*) ensurepip="--altinstall" ;; \
        esac; \
         ./python -E -m ensurepip \
                $ensurepip --root=/ ; \
Looking in links: /tmp/tmpjsfxpm1x
Processing /tmp/tmpjsfxpm1x/setuptools-49.2.1-py3-none-any.whl
Processing /tmp/tmpjsfxpm1x/pip-20.2.1-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
Successfully installed pip-20.2.1 setuptools-49.2.1

Done! check:

[root@tutorialspots Python-3.8.6]# python3.8 --version
Python 3.8.6
[root@tutorialspots Python-3.8.6]# pip3.8 --version
pip 20.2.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

Leave a Reply