I am using CentOS in which i had removed libxml2 accidentally now it was showing the following error as follows:

There was a problem importing one of the Python modules required to run yum. The error leading to this problem was:

libxml2.so.2: cannot open shared object file: No such file or directory

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.3 (#1, Jun 18 2012, 08:55:31) [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

  • This is also a good time to you review your backup/disaster recovery system. ;-) – depquid Apr 17 '13 at 16:41

First go to http://vault.centos.org/. Find the version and architecture of CentOS you're using and download a copy of the libxml2 rpm (an example full path is http://vault.centos.org/4.1/os/i386/CentOS/RPMS/libxml2-2.6.16-6.i386.rpm).

Once downloaded, install it with rpm:

# rpm -i libxml2-2.6.16-6.i386.rpm
| improve this answer | |

Since the package installer yum relies on libxml2, it cannot be used to reinstall libxml2. You can:

  • copy the file from a different machine running the same version of CentOS
  • boot the machine from an installation or live CD and copy the file over (or use another machine you can free up for rebooting and copy it over)
  • if you have all the tools to build libxml2 installed (gcc, autotools etc) you might also try to download and install the source for libxml2 and install it from scratch (if you don't have the tools, you cannot install them, although you might be able to get away with 'just' having gcc and installing the others from source)
| improve this answer | |

Use yum to reinstall the package, if need be boot from installation media into rescue mode do to do. As the library is required by yum, perhaps copying it from the rescue environment is enough to get yum going, and then reinstall.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.