Linux编译安装Python3.X版本并保留系统自带的Python2.X版本

以CentOS为例子:

yum install wget
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel


cd /usr/local/src
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
tar -zxf /usr/local/src/Python-3.6.0.tgz && cd Python-3.6.0


mkdir /usr/local/python3
./configure --prefix=/usr/local/python3
make && make altinstall


# 关键一步,建立链接 
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3          # 可直接使用 "python3"
ln -s /usr/local/python3/bin/pip3.6  /usr/bin/pip3               # 可直接使用 "pip3"


# 最后测试下 
python3
pip3

你可能感兴趣的:(Python)