1.下载 wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz并解压tar -xzvf Python-3.8.0.tgz
2. 安装依赖
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 libffi-devel -y
3. 编译安装
./configure prefix=usr/local/python3
make -j4 && make install
4. 配置环境及软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5. 上述配置存在一些问题,比如安装了flask,直接运行flask run会提示命令找不到
建议将/usr/local/python3/bin添加到环境变量中
vim .bash_profile