• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

python:Centos6下python2.7的安装

python 搞代码 4年前 (2022-01-09) 27次浏览 已收录 0个评论

1)编译安装python2.7

[root@mysql-master ~]# python -VPython 2.6.6查看python的版本信息(之前的yum是通过yum安装的)[root@mysql-master src]# wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz[roo<strong style="color:transparent">本文来源gao@daima#com搞(%代@#码@网&</strong>t@mysql-master src]# file Python-2.7.9.tar.xz Python-2.7.9.tar.xz: xz compressed data[root@mysql-master src]# xz -d Python-2.7.9.tar.xz [root@mysql-master src]# lsdebug  kernels  Python-2.7.9.tar[root@mysql-master src]# tar -xf Python-2.7.9.tar [root@mysql-master src]# cd Python-2.7.9[root@mysql-master Python-2.7.9]# ./configure [root@mysql-master Python-2.7.9]# make && make install[root@mysql-master Python-2.7.9]# echo $?0[root@mysql-master Python-2.7.9]# /usr/local/bin/python2.7 -VPython 2.7.9[root@mysql-master Python-2.7.9]# mv /usr/bin/python /usr/bin/python2.6mv:是否覆盖"/usr/bin/python2.6"? yes[root@mysql-master Python-2.7.9]# ln -s /usr/local/bin/python2.7 /usr/bin/python[root@mysql-master Python-2.7.9]# python -VPython 2.7.9

2)调整yum的配置

因为yum使用会调用python的信息,避免重新安装python后,yum出现报错,编辑yum的文件:[root@mysql-master Python-2.7.9]# sed -i 's@#!/usr/bin/python@#!/usr/bin/python2.6@g' /usr/bin/yum[root@mysql-master Python-2.7.9]# cat /usr/bin/yum |head#!/usr/bin/python2.6import systry:    import yumexcept ImportError:    print >> sys.stderr, """\There was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was:   %s[root@mysql-master Python-2.7.9]# pythonPython 2.7.9 (default, Nov 16 2016, 19:53:47) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> print "hello,world"hello,world到此,python2.7的基本安装也完成了。

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:python:Centos6下python2.7的安装
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址