Python3源码编译安装
Python3编程语言
编译平台环境
个人准备了一台Centos7的Linux服务器,X86 64位操作系统,最小化安装。静态IP:192.168.0.150(itdeer)
系统检查
[root@itdeer ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@itdeer ~]# uname -a
Linux itdeer 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
依赖安装
[root@itdeer ~]# yum -y install gcc make zlib*
[root@itdeer ~]# yum -y install libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
编译
[1] 下载解压源码
[root@itdeer ~]# wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz
[root@itdeer ~]# tar -zxvf Python-3.7.6.tgz
[root@itdeer ~]# cd Python-3.7.6
[2] 配置及编译
[root@itdeer Python-3.7.6]# ./configure --enable-optimizations --prefix=/usr/local/python3
[root@itdeer Python-3.7.6]# make && make install
[3] 软链
[root@itdeer Python-3.7.6]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@itdeer Python-3.7.6]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[4] 验证
[root@itdeer Python-3.7.6]# python3
Python 3.7.6 (default, Feb 18 2020, 15:15:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
扩展
支持SSL
在执行./configure之前需要安装openssl
yum install openssl
执行配置./configure --with-ssl --enable-optimizations --prefix=/usr/local/python3
之后再做make && make install