升级python而不打破yum [英] Upgrade python without breaking yum

查看:137
本文介绍了升级python而不打破yum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近通过从源代码编译,在CentOS机器上安装了Python 2.7.3。 Python 2.7.3安装在/opt/python2.7,当我安装它,我只是改变了/ usr / bin / python指向新版本。这显然是错误的,因为当我做了它打破了yum。我会得到以下。

 导入一个Python模块
需要运行yum时出现问题。导致此问题的错误是:

没有名为yum的模块

请安装提供此模块的软件包,或
验证模块安装是否正确。

这可能是上面的模块不匹配
当前版本的Python,它是:
2.7.3(默认,2012年5月15日,17:45:42 )
[GCC 4.4.4 20100726(Red Hat 4.4.4-13)]

如果你自己不能解决这个问题,请去
yum faq:
http://yum.baseurl.org/wiki/Faq

我改变了/ usr / bin / python指向python 2.6.6,但现在的2.6.6是python的默认版本。任何想法如何解决这个问题?

解决方案

我写了一个了解如何在CentOS上安装Python 2.7.3(和3.3.0) 6.您不应该更改Python的系统版本,因为它会破坏系统(如您所知)。



安装其他版本可以正常工作单独保留原始系统版本。这可以通过在安装另一个版本的Python时使用 make altinstall (而不是普通的 make install )来实现。 / p>

有多个版本的Python可用通常不是一个大问题,只要你记得键入包括版本号的全名(例如python2.7或 easy_install-2.7)。如果你从virtualenv做你所有的Python工作,版本控制是为你处理,所以请确保你安装和使用virtualenv!


I recently installed Python 2.7.3 on a CentOS machine by compiling from source. Python 2.7.3 is installed at /opt/python2.7 and when I installed it I just changed /usr/bin/python to point to the new version. This apparently is wrong though because when I did it it broke yum. I would get the following.

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, May 15 2012, 17:45:42) 
[GCC 4.4.4 20100726 (Red Hat 4.4.4-13)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

I changed /usr/bin/python to point back to the python 2.6.6 but now 2.6.6 is the default version of python. Any idea how to fix this?

解决方案

I wrote a quick guide on how to install Python 2.7.3 (and 3.3.0) on CentOS 6. You are not supposed to change the system version of Python because it will break the system (as you found out).

Installing other versions works fine as long as you leave the original system version alone. This can be accomplished by using make altinstall (instead of the normal make install) when installing another version of Python.

Having multiple versions of Python available is usually not a big problem as long as you remember to type the full name including the version number (for example "python2.7" or "easy_install-2.7"). If you do all your Python work from a virtualenv the versioning is handled for you, so make sure you install and use virtualenv!

这篇关于升级python而不打破yum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆