一,安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel readline-devel tk-devel gcc make
安装libffi-devel依赖
yum install libffi-devel -y
注意:如果不安装这个包,python3可以装成功,但是后面装flask、uwsgi等依赖python3中有个内置模块叫ctypes时会报错。报错ModuleNotFoundError: No module named ‘_ctypes‘。需要安装依赖包和重新编译安装python3。 参考:https://blog.csdn.net/qq_36416904/article/details/79316972
二,下载python源码包
python官网https://www.python.org/downloads/source/ ,按需选择自己的版本,本文选择3.7.7版本,下载 Python-3.7.7.tgz即可
三,解压安装python源码包
1,解压
tar -zxvf Python-3.7.7.tgz
2,安装
进入解压后的目录进行编译和安装
cd Python-3.7.7/ [root@localhost Python-3.7.7]#
[root@localhost Python-3.7.7]# ./configure --prefix=/usr/local/python3
[root@localhost Python-3.7.7]# make && make install
执行完后显示安装成功
3,建立命令软链接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
编译安装完成
标签:Python,离线,devel,Centos7,3.7,usr,安装,python3 From: https://www.cnblogs.com/yizhipanghu/p/17460056.html