还是记下来好。
先看看什么版本
[root /]# python -V
Python 2.6.6
安装一些需要的包
[root /]# yum install -y gcc make openssl-devel bzip2-devel expat-devel gdbm-devel readline
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.usc.edu
* extras: mirror.chpc.utah.edu
* updates: linux.mirrors.es.net
Package gcc-4.4.7-16.el6.x86_64 already installed and latest version
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
Package openssl-devel-1.0.1e-42.el6_7.4.x86_64 already installed and latest version
Package bzip2-devel-1.0.5-7.el6_0.x86_64 already installed and latest version
Package expat-devel-2.0.1-11.el6_2.x86_64 already installed and latest version
Package gdbm-devel-1.8.0-38.el6.x86_64 already installed and latest version
Package readline-6.0-4.el6.x86_64 already installed and latest version
Nothing to do
[root /]# wget https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz
–2016-04-29 05:56:28–
https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz
Resolving www.python.org… 23.235.44.223
Connecting to www.python.org|23.235.44.223|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 19435166 (19M) [application/octet-stream]
Saving to: `Python-3.4.4.tgz’
解压包
[root /]# tar -xzf Python-3.4.4.tgz
进入解压后的文件夹
[root /]# cd Python-3.4.4
安装
[root Python-3.4.4]# ./configure
[root Python-3.4.4]# make all
[root Python-3.4.4]# make install
查询python版本,发现还是老版本
[root Python-3.4.4]# python -V
Python 2.6.6
指向新安装的python3.4
[root Python-3.4.4]# mv /usr/bin/python /usr/bin/python2.6
[root Python-3.4.4]# ln -s /usr/local/bin/python3.4 /usr/bin/python
再次查询
[root Python-3.4.4]# python -V
Python 3.4.4
修改yum
vi /usr/bin/yum IT网
把文件头部的#!/usr/bin/python改成#!/usr/bin/python2.6 保存退出即可
参考网站:
http://www.68idc.cn/help/server/linux/20150317279470.html
http://linux.it.net.cn/CentOS/course/2014/0504/1059.html