0%

CentOS 7 源代码编译安装 Python 3

下载源码

在 [Python 官网][1]获取源代码地址

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

编译

1
2
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
./configure --prefix=/usr/local/python3 --enable-optimizations
安装编译套件

1
yum groupinstall "Development tools"

安装

1
2
3
make
make test
make install

更改默认版本配置

1
2
update-alternatives --install /usr/bin/python python /usr/local/python3/bin/python3 2
update-alternatives --config python

测试

1
2
$ python3 -V
Python 3.6.5

参考