码迷,mamicode.com
首页 > 编程语言 > 详细

centos下python版本升级为2.7.6

时间:2014-08-04 18:20:18      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:python版本升级

操作系统:vm centos6.5 64


1.当前的python版本为2.6.6

python -V
Python 2.6.6


2.下载python2.7.6

wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz


3.解压python

tar -jxvf Python-2.7.6.tar.bz2

发现没有bzip2软件包

yum install bzip2


4.安装

cd Python-2.7.6 &&  ./configure
没有gcc支持:error: no acceptable C compiler found in $PATH

安装gcc

yum install gcc

继续安装python

./configure && make all && make install && make clean && make distclean


5.建立软连接

mv /usr/bin/python /usr/bin/pythonh2.6.6
ln -sv /usr/local/bin/python2.7 /usr/bin/python


6.查看当前python的版本

python -V
Python 2.7.6


7.当你尝试yum的时候

yum list | grep python

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, Aug 1 2014, 18:27:15) 
[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

当系统centos6.5中的python软链接到python2.7.6后,yum与python2.7.6不兼容,要指定yum的python版本

vi /usr/bin/yum
#将#!/usr/bin/python改为#!/usr/bin/python2.6.6

#或者是
sed -i ‘s/python/python2.6.6/‘ /usr/bin/yum


8.既然都已经升级了python,顺带就安装pip

安装setuptools

wget https://bitbucket.org/pypa/setuptools/get/default.tar.gz#egg=setuptools-dev
tar zxvf default.tar.gz
cd pypa-setuptools-60d0c9f24d88/
python setup.py install

安装pip

wget https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz --no-check-certificate
tar zxvf pip-1.5.tar.gz 
cd pip-1.5
python setup.py install


本文出自 “运维小卒” 博客,谢绝转载!

centos下python版本升级为2.7.6,布布扣,bubuko.com

centos下python版本升级为2.7.6

标签:python版本升级

原文地址:http://8721349.blog.51cto.com/8711349/1535453

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!