📅  最后修改于: 2023-12-03 14:59:54.565000             🧑  作者: Mango
在CentOS上安装Python 3.9可以使用yum和源码两种方式。本文将为大家介绍这两种方式的操作步骤。
打开终端,使用以下命令更新yum:
sudo yum update -y
安装EPEL源:
sudo yum install epel-release -y
安装IUS源:
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install yum-utils -y
sudo yum-config-manager --enable remi
sudo yum update -y
安装Python 3.9:
sudo yum install python39 -y
安装pip:
sudo yum install python39-pip -y
验证Python和pip:
python3.9 -V
pip3.9 -V
安装依赖:
sudo yum groupinstall 'Development Tools' -y
sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel \
sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y
从Python官网下载源码包:
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 -j8
sudo make altinstall
验证Python和pip:
python3.9 -V
pip3.9 -V
现在,您已成功在CentOS上安装Python 3.9!