貌似CentOS 6.X系统默认安装的Python都是2.6版本的,平时使用以及很多的库都是要求用到2.7版本或以上,所以系统升级Python2.7是不可避免的
CentOS下python2.6升级2.7
Linux
date 2018年5月18日15:51:45
查看当前系统版本
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. dlopen("/usr/lib64/python2.6/lib-dynload/readline.so", 2); import readline # dynamically loaded from /usr/lib64/python2.6/lib-dynload/readline.so >>>
1.安装devtoolset
$ yum groupinstall "Development tools"
2.安装编译Python需要的包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
3.下载并解压Python 2.7.9的源代码
$ cd /tmp/ $ wget --no-check-certificate https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz $ tar xf Python-2.7.9.tar.xz $ cd Python-2.7.9
4.编译与安装Python 2.7.9
$ ./configure --prefix=/usr/local $ make && make altinstall
5.配置软连接,让系统pyhon默认指向python2.7.9
备份 mv /usr/bin/python /usr/bin/python2.6_temp 制作软连接 ln -s /usr/local/bin/python2.7 /usr/bin/python $ python -V # 查看Python 2.7.9
6.yum与python2.7不兼容,修改yum文件
vim /usr/bin/yum 将"!/usr/bin/python"改为"!/usr/bin/python2.6"
7.配置环境变量
$ vim /etc/profile # 添加如下内容: PY_HOME=/usr/local/bin/python2.7 export PATH=$PY_HOME/bin:$PATH
8.启动环境变量配置
source /etc/profile or . /etc/profile echo $PATH #查看环境变量中是否包含python路径 [root@abcdocker ~]# echo $PATH /usr/local/bin/python2.7/bin:/usr/local/node/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
9.完美升级完成
相关文章:
- Kubernetes 1.14 二进制集群安装
- Nagios 配置及监控
- 自动化运维工具之–Cobbler
- Kuerbernetes 1.11 集群二进制安装