Install Python 3.9 on Centos 7 or 8

Contents

CentOS has python2.7.5 and python3.6.8 inculded. I’d like to have latest python installed for some new features.

1
yum remove python3
1
2
3
yum update -y
yum groupinstall -y 'Development Tools'
yum install -y gcc openssl-devel bzip2-devel libffi-devel

Pyhon source code can be found here(FTP server).

1
2
3
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tar.xz
tar zxf Python-3.9.6.tgz
cd Python-3.9.6
1
2
3
./configure prefix=/usr/local/python3.9
make
make install
1
2
ln -s /usr/local/python3.9/bin/python3.9 /usr/bin/python3
ln -s /usr/local/python3.9/bin/pip3.9 /usr/bin/pip3
1
2
python3 --verion
pip3 --version

Now we are good to go!

1
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

or just change registry temperarily:

1
pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple