Videos
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
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
seeing your post i decided to stop trying to install 3.7 (already half an hour of head banging) and went for 3.6 using IUS. however, when i checked the version i had just installed, i saw this:
$ python3 -V
Python 3.7.4
so it looks like i got 3.7 even though this is the yum command i used:
$ yum install python36
anyway, it worked for me, perhaps it will work for you? a little bizarre, imo.
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
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.