centos安装python3与python2共存
网上的教程一搜很多,质量参差不齐,好多都是直接转发的,自己都没试试(导致一个错误的方法传的到处都是,无力吐槽),这里我给出一个我自己安装成功的例子。系统是centos6.8,python是3.6.5。
1、安装依赖环境
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
2、新建目录
mkdir -p /usr/local/Python3
3、进入到目录中
cd /usr/local/Python3
4、下载安装包解压
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -zxvf Python-3.6.5.tgz
5、进入解压后的目录编译安装
cd Python-3.6.5
./configure --prefix=/usr/local/Python3
make
make install
6、安装好了,建立软连接
ln -s /usr/local/Python3/bin/python3 /usr/bin/python3
ln -s /usr/local/Python3/bin/pip3 /usr/bin/pip3
7、测试
python3
pip3 list