一、安装python
1、安装依赖环境
yum install gcc -y
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install zlib zlib-devel openssl -y
yum install openssl-devel -y
yum install libffi-devel -y
2、到官网下载Python包
进入官网(https://www.python.org/)点击downloads,再点击linux
选择要下载的版本包
或者使用wget方式下载
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
3、将下载好的python包移到Linux下,然后解压
cd /usr/local tar -zxvf Python-3.9.1.tgz
4、创建安装目录
mkdir /usr/local/python3.9/
5、进入解压后的目录,配置安装环境
cd /usr/local/Python-3.9.1 ./configure --prefix=/usr/local/python3.9/
--prefix 参数是指定安装目录
6、编译并安装
make && make install