Install Python 3.9 on Centos 7 or 8
CentOS has python2.7.5 and python3.6.8 inculded. I'd like to have latest python installed for some new features.
Remove default python3
yum remove python3
Install prerequisite packages
yum update -yyum groupinstall -y 'Development Tools'yum install -y gcc openssl-devel bzip2-devel libffi-devel
Download python source code
Pyhon source code can be found here(FTP server).
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tar.xztar zxf Python-3.9.6.tgzcd Python-3.9.6
Compile and install
./configure prefix=/usr/local/python3.9makemake install
Create soft links
ln -s /usr/local/python3.9/bin/python3.9 /usr/bin/python3ln -s /usr/local/python3.9/bin/pip3.9 /usr/bin/pip3
Verify
python3 --verionpip3 --version
Now we are good to go!
Optional: change pip registry
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
or just change registry temperarily:
pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple