我看到了很多类似的问题,但没有一个能回答我遇到问题的确切部分(实际上是安装 Python RPM)。我的系统上的某个人在我的 64 位 CentOS 5.8 安装中删除了 /usr/bin/python 和 /usr/bin/python2.4。我从源代码重新编译了 Python 2.4,但现在每当我尝试 yum 安装任何东西时,我都会收到以下错误:
[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
答案1
使用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
来安装系统包的当前版本(如果这些版本不是最新的)。
答案2
答案3
对于您提到的配置(64 位 CentOS 5.8),请从这里下载您的软件包(python 及其依赖项):http://mirror.centos.org/centos/5.8/updates/x86_64/RPMS/
然后做一个转速-ivh下载后,使用以下命令安装 yumrpmbuild --重建 yum*.src.rpm