Centos7编译安装python3.7

环境:

CentOS Linux release 7.5.1804
python3.7.3

前期准备:

安装相关依赖包,采用yum安装.

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 gcc gcc-c++ zlib zlib-devel libffi-devel gcc kernel-devel kenel-headers make bzip2 #相应依赖包

开始安装

解压下载的安装包

tar -xf Python-3.7.3.tgz #解压下载的安装包
cd cd Python-3.7.3 #进入目录
./configure --enable-optimizations #编译检测
make && make install #编译并安装

不出意外的话应该是安装成功的,要是有报错的话需要在看看是否缺少相关依赖包或者是环境变量。

一件下载安装脚本

本脚本从org下载安装包,并yum安装所有依赖包,自动安装python3.7.3

wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz &&\
tar xf Python-3.7.3.tgz &&\
cd Python-3.7.3 &&\
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 gcc gcc-c++ zlib zlib-devel libffi-devel gcc kernel-devel kenel-headers make bzip2  #相应依赖包 &&\
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 gcc gcc-c++ zlib zlib-devel libffi-devel gcc kernel-devel kenel-headers make bzip2 #防失败执行多一次 &&\
./configure --enable-optimizations &&\
make && make install
    原文作者:lemon
    原文地址: https://segmentfault.com/a/1190000019690270
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞