python2.7.X 升级至Python36.X
安装Python3 项目是在py3环境下进行编码的,正好Centos默认的py版本是2,我们还需要安装py3才能让程序run起来,在此之前,需要安装开发工具包,因为要编译安装Python 1 [root@CentOS ~]# yum -y group install "Development Tools" 安装Python的依赖包,不安装依赖可能安装完成后没有pip3 软件。[root@CentOS ~]# yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel vim
[root@CentOS ~]# tar xf Python-3.5.3.tgz [root@CentOS ~]# cd Python-3.5.3[root@CentOS Python-3.5.3]# ./configure --prefix=/usr/local/python3.5[root@CentOS Python-3.5.3]# make[root@CentOS Python-3.5.3]# make altinstall
为pip3和python3创建链接
[root@CentOS Python-3.5.3]# ln -fs /usr/local/python3.5/bin/python3 /usr/local/bin/[root@CentOS Python-3.5.3]# ln -fs /usr/local/python3.5/bin/pip3 /usr/local/bin/[root@CentOS Python-3.5.3]# mv /usr/bin/python/usr/bin/python_old[root@CentOS Python-3.5.3]# ln -fs /usr/local/python3.5/bin/python3.5 /usr/bin/python[root@CentOS Python-3.5.3]# ln -fs /usr/local/python3.5/bin/pip3.5 /usr/bin/pip
验证安装
[root@CentOS Python-3.5.3]# pip -Vpip 9.0.1 from /usr/local/python3.5/lib/python3.5/site-packages (python 3.5)[root@CentOS Python-3.5.3]# python -VPython 3.5.3
修改yum文件,否则yum将无法下载
vim /usr/bin/yum
将
#!/usr/bin/python
修改为
#!/usr/bin/python2.7
保存即可生效