python入门系列之一:Centos6下python2.7的安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python入门系列之一:Centos6下python2.7的安装相关的知识,希望对你有一定的参考价值。
1)编译安装python2.7
[[email protected] ~]# python -V Python 2.6.6 查看python的版本信息(之前的yum是通过yum安装的) [[email protected] src]# wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz [[email protected] src]# file Python-2.7.9.tar.xz Python-2.7.9.tar.xz: xz compressed data [[email protected] src]# xz -d Python-2.7.9.tar.xz [[email protected] src]# ls debug kernels Python-2.7.9.tar [[email protected] src]# tar -xf Python-2.7.9.tar [[email protected] src]# cd Python-2.7.9 [[email protected] Python-2.7.9]# ./configure [[email protected] Python-2.7.9]# make && make install [[email protected] Python-2.7.9]# echo $? 0 [[email protected] Python-2.7.9]# /usr/local/bin/python2.7 -V Python 2.7.9 [[email protected] Python-2.7.9]# mv /usr/bin/python /usr/bin/python2.6 mv:是否覆盖"/usr/bin/python2.6"? yes [[email protected] Python-2.7.9]# ln -s /usr/local/bin/python2.7 /usr/bin/python [[email protected] Python-2.7.9]# python -V Python 2.7.9
2)调整yum的配置
因为yum使用会调用python的信息,避免重新安装python后,yum出现报错,编辑yum的文件: [[email protected] Python-2.7.9]# sed -i ‘[email protected]#!/usr/bin/[email protected]#!/usr/bin/[email protected]‘ /usr/bin/yum [[email protected] Python-2.7.9]# cat /usr/bin/yum |head #!/usr/bin/python2.6 import sys try: import yum except ImportError: print >> sys.stderr, """There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: %s [[email protected] Python-2.7.9]# python Python 2.7.9 (default, Nov 16 2016, 19:53:47) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "hello,world" hello,world 到此,python2.7的基本安装也完成了。
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1873670
以上是关于python入门系列之一:Centos6下python2.7的安装的主要内容,如果未能解决你的问题,请参考以下文章
OPEN(SAP) UI5 学习入门系列之一:扫盲与热身(下)