CentOS7.2安装Python3.6和python2.7共存

首先去官网下载python3.6的linux下代码压缩包

https://www.python.org/


环境准备:#yum -y install gcc openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
mkdir /usr/local/python3
准备安装python
./configure --prefix=/usr/local/python3 --enable-optimizations
make

make install

ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
cd /usr/bin
mv python python.bak

mv python3 python

cd /usr/bin
mv python python.bak
mv python3 python
在etc/profile最后一行中加入变量
export PATH="$PATH:/usr/local/python3/bin"
输入Python

>>>python 3.6
输入pip3 -V 检查是否安装成功

你可能感兴趣的:(Python)