Centos 7 安装 Python3.7

1. 获取 root 权限

su
# 输入密码

2.安装一些工具包

yum -y groupinstall "Development tools"
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
yum install libffi-devel -y

3.下载安装包并解压

cd ~
# 这里也可以安装自己需要的版本,如:3.7.*
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf  Python-3.7.0.tar.xz

4.编译安装

mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install

5.创建软连接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

5.验证安装

python3 -V
pip3 -V

验证结果

Last Updated: 8/21/2019, 5:23:08 PM