Centos7升级python3.9
1.系统升级
yum update -y
yum -y groupinstall "Development tools"
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel
2.下载python3.9源码包
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
3.解压:
tar -xzf Python-3.9.1.tgz
4.然后 cd Python-3.9.1 文件目录下。创建Python-3.9.1的安装目录:
mkdir /usr/local/python3/
5.开始编译安装。
在Python-3.9.1目录下生成安装配置文件:
./configure --prefix=/usr/local/python3
然后执行编译和安装:
make && make install
7.修改系统路径和指向。
安装完成后,接下来开始配置系统连接和路径指针。
首先把centos旧的python版本移走:
mv /usr/bin/python /usr/bin/python_old
mv /usr/bin/pip /usr/bin/pip_old
或者不移走,选择备份:
cp /usr/bin/python /usr/bin/python.bak
cp /usr/bin/pip /usr/bin/pip.bak
最后修改系统软链接:
ln -s /usr/local/python3/bin/python3.9 /usr/bin/python
ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip
E2j2hZw!G6zX9qg gitlab
标签:bin,升级,python,devel,Centos7,usr,pip,3.9,python3.9 From: https://www.cnblogs.com/elliotzsh/p/centos7-upgrade-python39-z2bfnz9.html