Linux

/usr/bin/python (Python 2.4) 在 CentOS 5 上被刪除。我從原始碼編譯但 yum 仍然壞了。我怎樣才能讓一切恢復到原來的樣子?

  • December 21, 2012

我看到很多其他類似的問題,但沒有一個回答我遇到問題的確切部分(實際上是安裝 Python RPM)。我的系統上有人在我的 64 位 CentOS 5.8 安裝中刪除了 /usr/bin/python 和 /usr/bin/python2.4。我從原始碼重新編譯了 Python 2.4,但現在每當我嘗試 yum install any 時,我都會收到以下錯誤:

[root@cerulean-OW1 ~]# yum install httpd
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.4 (#1, Dec 16 2012, 09:16:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]

If you cannot solve this problem yourself, please go to
the yum faq at:
 http://wiki.linux.duke.edu/YumFaq

我檢查了http://wiki.linux.duke.edu/YumFaq它說如下:

If you are getting a message that yum itself is the missing module then you probably installed it incorreclty (or installed the source rpm using make/make install). If possible, find a prebuilt rpm that will work for your system like one from Fedora or CentOS. Or, you can download the srpm and do a

rpmbuild --rebuild yum*.src.rpm 

我試著去http://rpm.pbone.net/index.php3/stat/4/idpl/17838875/dir/centos_5/com/python-2.4.3-46.el5.x86_64.rpm.html安裝Python ,導致以下錯誤:

[root@cerulean-OW1 ~]# rpm -Uvh python-2.4.3-46.el5.x86_64.rpm                  
error: Failed dependencies:
   python-libs-x86_64 = 2.4.3-46.el5 is needed by python-2.4.3-46.el5.x86_64

所以我嘗試安裝 python-libs-x86_64,結果如下:

[root@cerulean-OW1 ~]# rpm -Uvh python-libs-2.4.3-46.el5_8.2.x86_64.rpm
warning: python-libs-2.4.3-46.el5_8.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 192a7d7d
Preparing...                ########################################### [100%]
       package python-libs-2.4.3-46.el5_8.2.x86_64 is already installed
       file /usr/lib64/libpython2.4.so.1.0 from install of python-libs-2.4.3-46.el5_8.2.x86_64 conflicts with file from package python-libs-2.4.3-46.el5_8.2.x86_64

使用 RPM 的--replacefiles --replacepkgs--nodeps選項來強制重新安裝這些軟體包:

rpm --replacefiles --replacepkgs --nodeps -ivh python-libs-2.4.3-46.el5_8.2.x86_64.rpm python-2.4.3-46.el5.x86_64.rpm 

一旦 python 再次處於半工作狀態,你應該使用yum distro-sync來安裝系統包的目前版本,如果這些恰好不是最新的。

是的,您應該從 RPM 重新安裝 python。我假設你有一些 Centos 安裝媒體,因為你顯然已經安裝了它。如果您不這樣做:

這可能會有所幫助1

請注意:您沒有提及特定版本或架構,因此該連結是在黑暗中刺傷

引用自:https://serverfault.com/questions/459529