Centos7安装Python3

1.安装编译工具

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

2.下载安装包解压

cd #回到用户目录
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf  Python-3.7.0.tar.xz

3.编译安装

mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.7.0
./configure --prefix=/usr/local/python3.7 --enable-optimizations
make #查看是否有必需依赖库
make install

4.创建软连接

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

5.验证

安装$ virtualenv 
$ virtualenv -p /usr/bin/python3.7 venv    # -p参数指定Python解释器程序路径
source venv/bin/activate
查询版本
python -V
pip3 -V

安装完毕!

你可能感兴趣的:(Centos7安装Python3)