【转载】CentOS 7安装Python3.5,并与Python2.7兼容并存

CentOS 7下安装Python3.5

CentOS7默认安装了python2.7.5,当需要使用python3的时候,可以手动下载Python源码后编译安装。

1.安装python3.5可能使用的依赖

1 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

 

2.下载python

wget "https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz"

3.解压下载好的压缩包

tar -zxvf Python-3.5.0.tgz

4.配置编译

1 sudo mkdir /usr/local/python3
2 sudo Python-3.5.0/configure --prefix=/usr/local/python3
3 sudo make
4 sudo make install

5.备份旧版本python,链接新版本python

在/usr/bin中有python、python2、python2.7三个文件依次指向后者

1 sudo mv python python.bak,
2 sudo ln -s /usr/local/python3/bin/python3  /usr/bin/python

6.修改yum配置文件

sudo vi /usr/bin/yum
 
将第一行指定的python版本改为python2.7(#!/usr/bin/python 改为 #!/usr/bin/python2.7)
【转载】CentOS 7安装Python3.5,并与Python2.7兼容并存_第1张图片
 
   

转载于:https://www.cnblogs.com/waylon/p/6569196.html

你可能感兴趣的:(【转载】CentOS 7安装Python3.5,并与Python2.7兼容并存)