- 更新系统软件包:运行以下命令来更新系统上的所有软件包:
sudo yum update -y
sudo yum groupinstall -y "Development Tools"
sudo yum install -y bzip2-devel expat-devel gdbm-devel \ ncurses-devel openssl-devel readline-devel \ sqlite-devel zlib-devel xz-devel libffi-devel
- 跳转到安装的目录
cd /home
- 下载Python 3.11.9源码:从Python官方网站下载Python 3.11.9的源码包:
wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz
- 解压源码包:解压下载的源码包:
tar xzf Python-3.11.9.tgz
- 构建和安装Python:切换到解压后的目录,配置构建选项并安装Python:
cd Python-3.11.9
LDFLAGS="${LDFLAGS} -Wl,-rpath=/usr/local/openssl/lib" ./configure --with-openssl=/usr/local/openssl
make
altinstall 参数用于防止覆盖系统默认的 python 可执行文件。
make altinstall
- 验证安装:安装完成后,验证Python 3.11.9是否已成功安装:
python3.11 --version