centos7 下python3和python2共存

在这里首先强调一下,Centos7系统自带的Python2我们不要删除,我们要做的是在Python2和python3并存

1、安装依赖包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make -y
centos7 下python3和python2共存
2、下载python安装包
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
centos7 下python3和python2共存
3、解压python安装包
tar -Jxvf Python-3.5.2.tar.xz
centos7 下python3和python2共存
4、配置安装路径
切入到解压目录下
./configure prefix=/usr/local/python3
5、编译安装
切入到解压目录下
make && make install
6、配置软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
centos7 下python3和python2共存
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
centos7 下python3和python2共存
7、导出之前python安装的包的清单
centos7 下python3和python2共存
centos7 下python3和python2共存
centos7 下python3和python2共存
8、安装清单
Pip3 install -r package.txt
centos7 下python3和python2共存

上一篇:Centos6.10 安装Python 2.7.16


下一篇:第二章 Python入门