Liunx系统升级自带的Python版本

一、查看系统信息

[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@localhost ~]# uname -r
2.6.-.el6.x86_64

二、查看已安装python版本

[root@localhost ~]# rpm -qa|grep python
python-2.6.-.el6.x86_64
libxml2-python-2.7.-.el6_3..x86_64
python-urlgrabber-3.9.-.el6.noarch
python-iwlib-0.1-1.2.el6.x86_64
python-libs-2.6.-.el6.x86_64
rpm-python-4.8.-.el6.x86_64
dbus-python-0.83.-6.1.el6.x86_64
python-iniparse-0.3.-2.1.el6.noarch
python-pycurl-7.19.-.el6.x86_64
libproxy-python-0.3.-.el6_3.x86_64
libreport-python-2.0.-.el6.centos.x86_64
newt-python-0.52.-.el6.x86_64
python-ethtool-0.6-.el6.x86_64
abrt-addon-python-2.0.-.el6.centos.x86_64
[root@localhost ~]# python -V
Python 2.6.

三、下载编译安装python2.7.5版本源码包

[root@localhost ~]# cd /usr/local/src
[root@localhost ~]# wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
[root@localhost ~]# tar xvf Python-2.7..tgz
[root@localhost ~]# cd Python-2.7.
[root@localhost ~]# ./configure
[root@localhost ~]# make all
[root@localhost ~]# make install
[root@localhost ~]# make clean
[root@localhost ~]# make distclean

四、将系统默认的python版本设置为2.7.5

[root@localhost ~]# rm /usr/bin/python
[root@localhost ~]# ln -s /usr/local/bin/python2. /usr/bin/python

五、检查升级后的python版本

[root@localhost ~]# python -V
Python 2.7.

(转)https://blog.csdn.net/wailaizhu/article/details/54612982

上一篇:python之模块copy,了解概念即可


下一篇:批量删除以及将String数组转换成Integer数组的奇淫技巧