CentOS 6.5 升级python到版本2.7.14
2018-01-19 17:15
441 查看
环境:CentOS 6.5 64bit
CentOS 6.5 64bit 默认python版本:
[dup@localhost Downloads]$ python --version
Python 2.6.6
源码安装python 2.7.14步骤:1.下载python 2.7.14源码
[dup@localhost Downloads]$ wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz2.解压
[dup@localhost Python-2.7.14]$ ./configure
[dup@localhost Python-2.7.14]$ make
[dup@localhost Python-2.7.14]$ sudo make install5.查看安装python版本信息[dup@localhost Python-2.7.14]$ /usr/local/bin/python2.7 --version
Python 2.7.14[dup@localhost Python-2.7.14]$ ll /usr/local/bin/
total 6668
-rwxrwxr-x 1 root root 101 Jan 19 00:53 2to3
-rwxrwxr-x 1 root root 99 Jan 19 00:53 idle
-rwxr-xr-x 1 root root 1461 Jan 17 18:59 libmcrypt-config
-rwxr-xr-x 1 root root 232465 Jan 17 19:04 mcrypt
lrwxrwxrwx 1 root root 6 Jan 17 19:04 mdecrypt -> mcrypt
-rwxr-xr-x 1 root root 2363 Jan 11 23:23 pcre-config
-rwxr-xr-x 1 root root 90015 Jan 11 23:23 pcregrep
-rwxr-xr-x 1 root root 181880 Jan 11 23:23 pcretest
-rwxrwxr-x 1 root root 84 Jan 19 00:53 pydoc
lrwxrwxrwx 1 root root 7 Jan 19 00:56 python -> python2
lrwxrwxrwx 1 root root 9 Jan 19 00:56 python2 -> python2.7
-rwxr-xr-x 1 root root 6273987 Jan 19 00:55 python2.7
-rwxr-xr-x 1 root root 1687 Jan 19 00:56 python2.7-config
lrwxrwxrwx 1 root root 16 Jan 19 00:56 python2-config -> python2.7-config
lrwxrwxrwx 1 root root 14 Jan 19 00:56 python-config -> python2-config
-rwxrwxr-x 1 root root 18547 Jan 19 00:53 smtpd.py
6.建立软连接,使系统默认的python指向python2.7,依次执行:
[dup@localhost Python-2.7.14]$ yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.14 (default, Jan 19 2018, 00:52:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
If you cannot solve this problem yourself, please go to
the yum faq at: http://yum.baseurl.org/wiki/Faq
CentOS 6.5 64bit 默认python版本:
[dup@localhost Downloads]$ python --version
Python 2.6.6
源码安装python 2.7.14步骤:1.下载python 2.7.14源码
[dup@localhost Downloads]$ wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz2.解压
[dup@localhost Downloads]$ tar zxvf Python-2.7.14.tgz3.更改工作目录
[dup@localhost Downloads]$ cd Python-2.7.144.编译安装
[dup@localhost Python-2.7.14]$ ./configure
[dup@localhost Python-2.7.14]$ make
[dup@localhost Python-2.7.14]$ sudo make install5.查看安装python版本信息[dup@localhost Python-2.7.14]$ /usr/local/bin/python2.7 --version
Python 2.7.14[dup@localhost Python-2.7.14]$ ll /usr/local/bin/
total 6668
-rwxrwxr-x 1 root root 101 Jan 19 00:53 2to3
-rwxrwxr-x 1 root root 99 Jan 19 00:53 idle
-rwxr-xr-x 1 root root 1461 Jan 17 18:59 libmcrypt-config
-rwxr-xr-x 1 root root 232465 Jan 17 19:04 mcrypt
lrwxrwxrwx 1 root root 6 Jan 17 19:04 mdecrypt -> mcrypt
-rwxr-xr-x 1 root root 2363 Jan 11 23:23 pcre-config
-rwxr-xr-x 1 root root 90015 Jan 11 23:23 pcregrep
-rwxr-xr-x 1 root root 181880 Jan 11 23:23 pcretest
-rwxrwxr-x 1 root root 84 Jan 19 00:53 pydoc
lrwxrwxrwx 1 root root 7 Jan 19 00:56 python -> python2
lrwxrwxrwx 1 root root 9 Jan 19 00:56 python2 -> python2.7
-rwxr-xr-x 1 root root 6273987 Jan 19 00:55 python2.7
-rwxr-xr-x 1 root root 1687 Jan 19 00:56 python2.7-config
lrwxrwxrwx 1 root root 16 Jan 19 00:56 python2-config -> python2.7-config
lrwxrwxrwx 1 root root 14 Jan 19 00:56 python-config -> python2-config
-rwxrwxr-x 1 root root 18547 Jan 19 00:53 smtpd.py
6.建立软连接,使系统默认的python指向python2.7,依次执行:
[dup@localhost Python-2.7.14]$ mv /usr/bin/python /usr/bin/python2.6.6
[dup@localhost Python-2.7.14]$ sudo ln -s /usr/local/bin/python2.7 /usr/bin/python7.再次检查python版本
[dup@localhost Python-2.7.14]$ python --version Python 2.7.14目前已经是新版本。8.解决系统 python 软链接指向 python2.7 版本后,因为yum是不兼容 python 2.7的,所以yum不能正常工作,需要指定 yum 的python版本。
[dup@localhost Python-2.7.14]$ yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.14 (default, Jan 19 2018, 00:52:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
If you cannot solve this problem yourself, please go to
the yum faq at: http://yum.baseurl.org/wiki/Faq
#vim /usr/bin/yum 将文件头部的 #!/usr/bin/python 改成 #!/usr/bin/python2.6.6
相关文章推荐
- CentOS 6.5 升级python到版本2.7.14
- CentOS6.5 升级 Python 2.7 版本详细介绍
- centos6.5系统将Python2.6.6升级到3.6.3版本
- CentOS6.5 升级 Python 2.7 版本
- CentOS6.5默认Python版本升级到python2.7.5
- Centos 6.5 升级python到版本各种版本
- Centos6.5 python升级成2.7版本出现的一些问题解决方法
- CentOS 6.5升级Python版本、修复yum和安装模块
- centos6.5升级Python2.7.14
- centos 6.5安装node npm并升级npm 到指定版本
- Centos6.5下升级Python版本
- Centos 6.5将python 2.6 升级到 2.7
- CentOS6.5升级git版本
- Centos 5.5升级Python到2.7版本
- 升级 Centos 6.5/6.7 的 php 版本
- CentOS 5升级python版本(2.4>2.7)
- centos6.5系统下将Python2.6.6升级为Python3.5.0
- CentOS6.5 Openssl版本升级
- centos6.5的php5.3.3这个版本怎么升级到5.6
- CentOS6.5在已有低版本环境下安装升级Apache+MySQL+PHP