centos7 源码安装python3.7

1、centos7默认没有wget,首先安装wget

 yum install wget

centos7 源码安装python3.7_第1张图片2、下载Python3.7安装包:

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

centos7 源码安装python3.7_第2张图片
3、解压安装文件

tar  -xvf  Python-3.7.0.tgz

centos7 源码安装python3.7_第3张图片
4、在Python-3.7.0文件目录下,配置安装目录:

 ./configure --prefix=/usr/python370 --with-ssl  

第一个参数指定安装位置,第二个安装ssl,不然以后pip安装东西会报错。
可以先使用:rpm -aq|grep openssl 查看ssl是否安装了。如果没有安装,可以执行:yum install openssl-devel -y 安装ssl
centos7 源码安装python3.7_第4张图片
centos7 源码安装python3.7_第5张图片
如果出现 error: no acceptable C compiler found in $PATH问题,主要是缺少c的编译器,如下图:centos7 源码安装python3.7_第6张图片
安装c和c++编译器

yum install gcc g++

centos7 源码安装python3.7_第7张图片
5、如果您想要一个发布版本,并且所有稳定的优化都处于活动状态

./configure --enable-optimizations

centos7 源码安装python3.7_第8张图片
6、编译源码执行:make
centos7 源码安装python3.7_第9张图片
7、安装执行: make install
如果出现zlib的问题:
在这里插入图片描述
安装zlib的相关库yum -y install zlib*
centos7 源码安装python3.7_第10张图片
如果出现ctypes的问题:
centos7 源码安装python3.7_第11张图片
3.7版本需要一个新的包libffi-devel,安装libffi-devel yum install libffi-devel -y
centos7 源码安装python3.7_第12张图片
编译安装的结果如下:centos7 源码安装python3.7_第13张图片

你可能感兴趣的:(python源码安装)