linux安装python3
1.先安装python3依赖的
yum -y install gcc
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
2.查看要下载的python版本
去官网找对应的python版本,我这里下载了3.9.12
3.下载python3
F12查看源码,获取下载网址
wget https://www.python.org/ftp/python/3.9.12/Python-3.9.12.tgz
4.解压
tar -zxvf Python-3.9.12.tgz
5.构建
cd Python-3.9.12
# 设置安装路径
./configure --prefix=/usr/local/python3.9
# 安装python3.9
make && make install
6.配置全局命令
# 设置软链接
sudo ln -s /usr/local/python3.9/bin/python3.9 /usr/bin/python39
sudo ln -s /usr/local/python3.9/bin/pip3.9 /usr/bin/pip39
# 查看版本
python39 -V