centos7升级python3.7

wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
## 安装报错找不到 _ctype zlib 等模块
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 -y install gcc kernel-devel kenel-headers make bzip2
yum -y install readline-devel libffi-devel
yum -y install e2fsprogs-devel uuid-devel libuuid-devel
# 解压文件
tar -xvf Python-3.7.1.tar.xz
# 进入到该文件夹
cd Python-3.7.1/
# --prefix 欲安装目录
./configure --prefix=/usr/local/python3.7 --enable-optimizations
# 编译安装,make时间比较长,大概需要15分钟
make
make install
rm -f /usr/bin/python
ln -s /usr/local/python3.7/bin/python3.7 /usr/bin/python
ln -s /usr/local/python3.7/bin/pip3 /usr/bin/pip3

# 还需要重新编译安装才有效

如果先make再yum,可能还找不到,需要再次configure

你可能感兴趣的:(编译)