CentOS 升级Python3.X和pip3
目的:实现python3 and python2 共存,pip2 and pip3共存
一、安装依赖
yum install openssl-devel -y
yum install zlib-devel -y
二、先安装Python3
到官网上下载
https://www.python.org/downloads/source/
1、解压
tar -xf Python-3.5.2.tar.xz
2、编译安装
./configure –prefix=/usr/local/python3
make && make install
此时已完成新版本的安装,但由于老版本还在系统中,所以需要将原来/usr/bin/python链接改为新的连接:a.先修改老的连接,执行:mv /usr/bin/python /usr/bin/python_bak。b.再建立新连接: ln -s /usr/local/python3.4/bin/python3.4 /usr/bin/python (建议不要这样做,会导致yum工具不能使用,最好建议生成软连接python3)
ln -s /usr/local/python3.4/bin/python3.4 /usr/bin/python3(推荐)
二、安装pip3
1、首先安装setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6.tar.gz
python3 setup.py build
python3 setup.py install
2、安装pip3
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2
python3 setup.py build
python3 setup.py install
安装完成之后我们再来看下python的bin目录下都有什么东西吧