Python Redhat版本问题

可能重复:
升级python而不会破坏yum

我正在运行一个Redhat虚拟机(2.6.18-274.el5 64位)。 为了使用浏览器,我在vm上安装了nodejs。 为了让nodejs运行,我必须将Python升级到2.6或更高版本。 我使用make altinstall从源代码安装了2.7。 然后我创build了一个硬连接从2.4到2.7。 检查python -V现在显示2.7是默认的。 这一切都很好,节点现在正在运行。

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.2 (default, Jul 2 2012, 23:35:52) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] If you cannot solve this problem yourself, please go to the yum faq at: http://wiki.linux.duke.edu/YumFaq 

我的问题是百胜餐饮。 它不再像寻找2.4版本的Python的旧版本那样工作了? 无论如何,我可以让他们两个在百胜和节点都使用不同的版本?

这里有两个问题。 一个是你打破了你的系统python。 Yum安装在python的网站包中。 如果你损坏了python,yum就会破坏。 打破系统python安装是一个愚蠢的想法。 也许你做了备份,或者有另一台可以移植原始2.4 python的姊妹机器。

另一个问题是在同一台机器上有几个python没有问题。 要安装Node.js,你必须简单地告诉它使用哪个python。 在运行./configure之前,设置PYTHON=/opt/local/my/path/to/python2.7/bin/python ,可能还有PYTHONHOME

你不应该覆盖系统的Python; 太多的脚本依赖于知道该解释器的行为。 您可以在/usr/local安装较新版本的Python,然后使用Python包virtualenv根据需要进一步隔离您的环境。

Interesting Posts