Ok, here's what finally worked for me.

I think the key to success was updating LD_LIBRARY_PATH and PATH to include openssl as I went.

Install and build openssl.

OpenSSL 1.1.1d 10 Sep 2019

cloned openssl repo

Pulled out latest(?) 1.1 branch

git checkout OpenSSL_1_1_1d -b 1_1_1d

./config --prefix=/opt/openssl
make
make install

Add /opt/openssl/lib to your LD_LIBRARY_PATH env var

Add /opt/openssl/bin to your PATH

Install and build python-3.7.6

I installed with --prefix=/opt/python-3.7.6

./configure --prefix=/opt/python-3.7.6  --enable-optimizations --with-openssl=/opt/openssl
make
make install

Add /opt/python-3.7.6/lib to your LD_LIBRARY_PATH env var

Add /opt/python-3.7.6/bin to your PATH

Final Config

LD_LIBRARY_PATH=/opt/openssl/lib:/opt/python-3.7.6/lib:

PATH=/opt/openssl/bin:/opt/python-3.7.6/bin:/opt/idea/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Answer from SRJ on Stack Overflow
🌐
GitHub
gist.github.com › wpupru › deda1cd96ea242d9a790e50cd0c97e9f
Install Python 3.7.0 on Centos 7 · GitHub
sudo su yum install -y wget gcc openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel ; cd /usr/src; wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz ; tar xzf Python-3.7.0.tgz ; cd Python-3.7.0 ; ./configure --enable-optimizations ; make altinstall ; rm -rf /usr/bin/python3 ; ln -s /usr/local/bin/python3.7 /usr/bin/python3 ; python3 -V uname -a
🌐
Vinod Pandey
vinodpandey.com › how-to-install-python3-on-centos-7
How to Install Python 3 on Centos 7 | Vinod Pandey
January 10, 2021 - Introduction In this tutorial we will install Python 3.6, 3.7, 3.8 & 3.9 on CentOS 7. The default python version in CentOS 7 is 2.7.5. If we forcefully upgrade or replace this version, yum and other utitiles may break causing the OS to become ...
Discussions

openssl - Going nuts: How to get python 3.7.6 installed on CentOS 7 - Stack Overflow
I have tried many ways of installing python3.7.6 on centos 7. Regardless of what I do, I always get the error that the SSL module is not available. I have tried basic install guides such as https:// More on stackoverflow.com
🌐 stackoverflow.com
Cleanest way to install Python 3.7 on CentOS 7 image
Have you considered usinh the official Python 3.7 Docker image ? More on reddit.com
🌐 r/docker
7
1
July 10, 2019
python - How to install pip specifically for Python3 on CentOS 7? - Stack Overflow
Yes, but the problem is that running ... Python3.7.3rc1 gives error ModuleNotFoundError: No module named 'pyperclip' but works fine for Python2.7.5. ... I see. How about running pip3? Does it show something to you? ... No, bash: pip3: command not found.... ... Think you've done a lot of work for a beginner unnecessarily. Try installing the python36 package that's the default supported python3.x series in centos ... More on stackoverflow.com
🌐 stackoverflow.com
Trying to install python3.9 on CentOS 7
Just curious, why are you sticking with CentOS 7 instead of upgrading to CentOS Stream 9, Rocky Linux 9, RedHat EL 9 or Alma 9? More on reddit.com
🌐 r/CentOS
7
10
October 19, 2022
🌐
TecAdmin
tecadmin.net › install-python-3-7-on-centos
How To Install Python 3.7 on CentOS/RHEL 7 & Fedora 34 ...
April 26, 2025 - Now remove downloaded source archive file from your system ... Check the latest version installed of python. Use command python3.7 instead of just python. ... Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp ... Hi everyone! You MUST install the ‘xz-devel’ package for centos ...
🌐
Medium
medium.com › @info_37956 › setting-up-python-3-7-development-environment-on-centos-7-server-c488807049bd
Setting Up Python 3.7 Development Environment on CentOS 7 Server | by Ibrahim Cisse | Medium
March 15, 2024 - I began by accessing my CentOS server via SSH. After successfully logging in, I switched to the root user to perform administrative tasks. ... With administrative privileges, I installed the necessary development tools using the yum groupinstall command. This ensured that I had all the essential tools required for compiling and building software packages. ... Next, I installed the required dependencies for Python 3.7 to ensure that all necessary libraries and packages were available for the installation process.
🌐
DEV Community
dev.to › mkalioby › install-python-3-7-on-centos-7-3i7b
Install Python 3.7+ on CentOS 7 - DEV Community
December 2, 2021 - This was my first time to install a recent version of Python on a CentOS. I always use Ubuntu and It is pretty easy using deadlysnakes PPA.
🌐
Reddit
reddit.com › r/docker › cleanest way to install python 3.7 on centos 7 image
r/docker on Reddit: Cleanest way to install Python 3.7 on CentOS 7 image
July 10, 2019 -

I would think CentOS + Python would be extremely common but I can't find an elegant way to do this.

These both work, but they take minutes to run and bloat the image:

method #1:

FROM centos:7
RUN yum update -y && yum -y install yum-utils && yum -y groupinstall development && yum -y install https://centos7.iuscommunity.org/ius-release.rpm
RUN yum install -y python36u

method #2:

FROM centos:7
RUN yum -y --enablerepo=extras install epel-release && yum clean all && yum -y update
RUN wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz && tar xzf Python-3.7.2.tgz
RUN cd Python-3.7.2 && ./configure --enable-optimizations && make altinstall
Find elsewhere
🌐
Centmin Mod
community.centminmod.com › threads › custom-python-3-7-3-8-3-9-3-10-rpm-builds-for-centos-7.22456
CentOS 7.x - Custom Python 3.7, 3.8, 3.9 & 3.10 RPM Builds For CentOS 7 | Centmin Mod Community Support Forums
February 5, 2022 - CentOS 7 by default uses Python 2.7 and has side by side install support up to Python 3.6 via YUM repository RPM packages. For Python 3.7 and higher,...
Top answer
1 of 3
6

You should have taken the default available python3, that is the python3.6 package in centos7 that would have been easier to setup rather than compile an unsupported version. Suggest you install the supported python3 package in centos

Try doing yum install python36 from repository

sudo yum install -y https://repo.ius.io/ius-release-el7.rpm

Update yum package

 sudo yum update

Install python36 along with pip

sudo yum install -y python36u python36u-libs python36u-devel python36u-pip

Below steps are for python3.7, suggest avoiding unsupported packages. Alternate Steps for pip setup for Centos You need to install pip for python3.7 series Step 1: First install the EPEL Repository

sudo yum install epel-release

Step 2: Installing pip

python37 -m pip

Step 3: Verify if pip was installed properly pip --version

If the command not found error shows up, try

python37 -m ensurepip
2 of 3
1

I also as you said "followed these steps religiously from this link: https://tecadmin.net/install-python-3-7-on-centos/."

It was not an option for me to install python3.6, as I explicitly needed 3.7. I was able to install using the following procedure:

# AFAIK, libffi-devel solved the "ModuleNotFoundError: No module named '_ctypes'" I had when I tried installing without it. 
yum install libffi-devel 

cd /usr/src
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar xzf Python-3.7.5.tgz
cd Python-3.7.5
./configure --enable-optimizations
make install  # Or: make altinstall
python3 -V
pip3 --version
rm -f /usr/src/Python-3.7.5.tgz

What I changed from the referenced article is the version (3.7.5 instead of 3.7.4) and in addition installed "libffi-devel". It could be that this one would have solved on 3.7.4 as well.

🌐
OS Radar
osradar.com › home › linux › install python 3.7 on centos 7 and fedora 27/28
Install Python 3.7 on centos 7 and Fedora 27/28 - Linux Windows and android Tutorials
October 4, 2018 - One of the top requirement of Python is the GCC compiler on your system. please login to ur system and Download the needed requirements for Python · #yum install gcc openssl-devel bzip2-devel libffi libffi-devel · Installing: bzip2-devel x86_64 1.0.6-13.el7 base 218 k gcc x86_64 4.8.5-28.el7_5.1 updates 16 M openssl-devel x86_64 1:1.0.2k-12.el7 base 1.5 M Installing for dependencies: cpp x86_64 4.8.5-28.el7_5.1 updates 5.9 M glibc-devel x86_64 2.17-222.el7 base 1.1 M glibc-headers x86_64 2.17-222.el7 base 678 k kernel-headers x86_64 3.10.0-862.6.3.el7 updates 7.1 M keyutils-libs-devel x86_64
🌐
Victordomingos
no-title.victordomingos.com › articles › 2020 › install_python_centos_linux › index.html
How to install the current Python version on CentOS Linux 7 | The No Title® Tech Blog
April 26, 2020 - The first disappointment with CentOS 7 was that it didn’t include Python 3. Even after updating the system software, all I got was Python 2.7.5 (which was released 7 years ago!), and in the default yum repositories all I could find was an older Python 3.6.8 version.
🌐
Google Groups
groups.google.com › g › vfx-platform-discuss › c › D-rdtZJV4nI
Python 3.7 on CentOS 7 (and 8)
I'm currently working on adding support for Python 3.7 on Isotropix Clarisse.On Windows and macOS, the official Python installer is easy to download and use. But on CentOS 7, official Python binaries in repositories go up to 3.6, not 3.7.
🌐
Dracula Servers
draculaservers.com › home › how to install python 3.x on centos 7
How to Install Python 3.x on CentOS 7 - Dracula Servers Tutorials
November 14, 2021 - In this tutorial we'll install Python 3.6 and Python 3.7 on a server running Centos 7 using 2 methods - from repositories & compiling from source.
🌐
GitHub
github.com › adrienverge › copr-python37
GitHub - adrienverge/copr-python37: Unofficial Python 3.7 packages for CentOS 7
This repository provides unofficial packages of Python 3.7 for CentOS 7 and 8, while waiting for official packaging upstream.
Author   adrienverge
🌐
Liquid Web
liquidweb.com › home › how to install python 3 on centos 7
Install Python 3 on CentOS 7: Easy Steps for Linux Users | Liquid Web
April 7, 2025 - In CentOS 7 releases prior to 7.7, it was necessary to make Python 3 available for installation by setting up third-party repositories, such as the IUS repository, because the CentOS base repository did not provide a Python 3 package.
🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › how to install latest version of python 3 on centos 7
How to Install Latest Version Of Python 3 on CentOS 7
November 10, 2022 - If you are using a CentOS release older than 7.7, you need to add IUS, a yum repository that provides newer software versions and includes Python 3.
🌐
Medium
rakeshjain-devops.medium.com › how-to-install-python-3-on-centos-7-7-using-yum-and-source-and-set-as-default-1dee13396f7
How to Install Python 3 on CentOS 7.7 using yum/source and set as Default | by Rakesh Jain | Medium
October 13, 2020 - You should see the version of Python 3 installed on your system as well as a change in the command prompt characters. Yum package manager usage python2 by default so after you make python3 as default the yum will break. [root@centos7 ~]# yum install ftp File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax · To fix this change the python interpreter to `/usr/bin/python2.7` in two files
🌐
Reddit
reddit.com › r/centos › trying to install python3.9 on centos 7
r/CentOS on Reddit: Trying to install python3.9 on CentOS 7
October 19, 2022 -

I've tried a few didnt online guides but nothing seems to be helping me achieve what I'm looking for. I have a Linux machine for my network environment that I use for automation. I'm trying to upgrade my python 3.6.8 to some version of 3.9.x. I want to remove python 3.6.8, install 3.9, and then put 3.9 as the default for every user on the box.

Current Version of Linux 3.10.0-1160.6.1.el7.x86_64

I'm not a linux pro but I know some things.