安装与卸载python的参考文档:https://www.cnblogs.com/ilovepython/p/11068845.html
服务器: 阿里云ecs 2 vCPU 4 GiB (型号 ecs.hfc5.large)
系统:centos 7.6
自带python环境:python 2
-----------------------------------------------------------
# 注意:不要卸载python2 ,系统自带很多程序用python写的,例如 yum (vim /usr/bin/yum)
-----------------------------------------------------------
# 准备依赖包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make -y
# 安装python3
wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tar.xz
tar xf Python-3.9.5.tar.xz && cd Python-3.9.5
./configure prefix=/usr/local/python3 && make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# 建立Python虚拟环境
cd /opt/
python3 -m venv py3
source /opt/py3/bin/activate