在CentOS系统上安装Python 3的步骤如下:
-
安装必要的构建工具和库:
sudo yum groupinstall -y "Development Tools"
sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
-
下载Python 3
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
下载失败就多执行几次。
-
解压下载的源码包:
tar zxvf Python-3.9.0.tgz
-
编译安装:
cd Python-3.9.0 ./configure --enable-optimizations make altinstall
-
验证安装:
python3 --version