最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

python:Centos6下python2.7的安装

来源:动视网 责编:小采 时间:2020-11-27 14:27:50
文档

python:Centos6下python2.7的安装

python:Centos6下python2.7的安装:1)编译安装python2.7[root@mysql-master ~]# python -V Python 2.6.6 查看python的版本信息(之前的yum是通过yum安装的) [root@mysql-master src]# wget https://www.python.org/ftp/python/2.7.9/Python
推荐度:
导读python:Centos6下python2.7的安装:1)编译安装python2.7[root@mysql-master ~]# python -V Python 2.6.6 查看python的版本信息(之前的yum是通过yum安装的) [root@mysql-master src]# wget https://www.python.org/ftp/python/2.7.9/Python


1)编译安装python2.7

[root@mysql-master ~]# python -V
Python 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
[root@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]# ls
debug 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 -V
Python 2.7.9
[root@mysql-master Python-2.7.9]# mv /usr/bin/python /usr/bin/python2.6
mv:是否覆盖"/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 -V
Python 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.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
[root@mysql-master 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的基本安装也完成了。

文档

python:Centos6下python2.7的安装

python:Centos6下python2.7的安装:1)编译安装python2.7[root@mysql-master ~]# python -V Python 2.6.6 查看python的版本信息(之前的yum是通过yum安装的) [root@mysql-master src]# wget https://www.python.org/ftp/python/2.7.9/Python
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top