原文地址: https://www.cnblogs.com/knighterrant/p/10719887.html
1、安装依赖文件
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2、解压文件
tar -zxvf Python-3.7.8.tgz
3、进入文件夹
cd Python-3.7.8
4、 编译且安装
4.1: 释放编译文件 Makefile
./configure --prefix=/opt/python37 # 指定安装目录为/opt/python37
4.2: 编译
make # 相当于把源码包里面的代码编译成linux服务器可以识别的代码
4.3:安装
make install
4.2.4.3合并
make && make install
5.配置环境变量
vim /etc/profile
export PYTHON_HOME=/opt/python37
export PATH=${PYTHON_HOME}/bin:$PATH
source /etc/profile
6.进入 python3
#python3
>>>
以上是centos
ubuntu 参考地址
https://blog.csdn.net/CANGYE0504/article/details/105757394/
来源:oschina
链接:https://my.oschina.net/yangcaoling/blog/4354975