首页 > 代码库 > Python2.7安装教程
Python2.7安装教程
作者:zhanhailiang 日期:2014-11-16
[root@~/software]# yum install bzip* [root@~/software]# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz [root@~/software]# tar zxvf Python-2.7.3.tgz [root@~/software]# cd Python-2.7.3 [root@~/software/Python-2.7.3]# ./configure [root@~/software/Python-2.7.3]# make && make install [root@~/software]# cd /usr/local/bin/ [root@/usr/local/bin]# ls -al python* lrwxrwxrwx 1 root root 7 Nov 16 18:24 python -> python2 lrwxrwxrwx 1 root root 9 Nov 16 18:24 python2 -> python2.7 -rwxr-xr-x 1 root root 6162217 Nov 16 18:23 python2.7 -rwxr-xr-x 1 root root 1624 Nov 16 18:24 python2.7-config lrwxrwxrwx 1 root root 16 Nov 16 18:24 python2-config -> python2.7-config lrwxrwxrwx 1 root root 14 Nov 16 18:24 python-config -> python2-config [root@/usr/local/bin]# /usr/local/bin/python -V Python 2.7.3
如此安装就完成了。但是因为部分软件,如node.js依赖python2.7,此时需要修改系统路径python命令指向2.7.3版本:
[root@/usr/local/bin]# cp /usr/bin/python /usr/bin/python.bak.2014.11.16 [root@/usr/local/bin]# rm /usr/bin/python [root@/usr/local/bin]# ln -s /usr/local/bin/python2.7 /usr/bin/python
如此,如果遇到yum出问题,如下“There was a problem importing one of the Python modules”:
[root@~/software/Python-2.7.3]# yum search bzip 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.3 (default, Nov 16 2014, 18:22:57) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
这是因为yum依赖老版本的python,可以按如下操作修复:
[root@~/software/Python-2.7.3]# vim /usr/bin/yum
修改第一行命令行,将python指向指定版本就行了:
1 #!/usr/bin/python2.6 2 import sys 3 try: 4 import yum
参考文章:http://www.tomtalk.net/wiki/Python
Python2.7安装教程
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。