CentOS 7.0 下 Python 2.7 升级到 Python 3.5

前段由于时间工做须要,要把 Centos 7.0 默认安装的 Python 2.7 升级到 Python 3.5。python

具体操做以下:c++

# 安装 gcc gcc-c++ 等编译工具软件sql

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ wget -y

 

# 建立保存软件的目录工具

mkdir /home/tools && cd /home/tools/

 

# 下载 Python 3.5 版本url

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

 

# 解压编译安装spa

tar -zxf Python-3.5.0.tgz mkdir /usr/local/python3 Python-3.5.0/configure --prefix=/usr/local/python3 make
make install

 

 # 这里须要备份还原系统 yum 命令使用的 Pyhon2.7 code

cd /usr/bin mv python python.bak ln -s /usr/local/python3/bin/python3 /usr/bin/python ln -s /usr/local/python3/bin/python3 /usr/bin/python3

 

# 修改yum配置文件sqlite

编辑 /usr/bin/yum 和 /usr/libexec/urlgrabber-ext-down 改为: #!/usr/bin/python2.7

 

如今能够愉快地使用 Python 3.5 了~blog