One of our CentOS servers has went into a strange state and is complaining that libpython2.7.so.1.0 cannot open shared object files. Yum is unusable and other features are failing to function (such as sending mail from the system, SSH'ing to it etc.) I really don't want to have to rebuild the server from scratch and I'm hoping someone can advise on a fix for me.

An example of the error I am presented with when running Yum:

/usr/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

I cannot use the pipe symbol (as I am having to manage the system via VMware console) and I cannot copy text from this console either, so if you require me to run any commands I will have to type the results out manually.

Answers to the questions asked on Stack Overflow:

Typing python into the CLI still works and opens Python (note the date/time stamp below is when this stopped working!):

Python 2.7.15 (default, Jun 18 2018, 08:40:16) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2 

Typing rpm --verify -a into the CLI returns the following:

$ rpm --verify -a
rpm: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
  • Do either of those library files exist on the system? As root, you can find them by first running updatedb and then locate libpython2.7.so.1.0 and locate libnss3.so. If they aren't there then that's where your problem is. – Nasir Riley Jul 6 '18 at 14:00
  • updatedb is not a command which is found. Neither is locate. We have done 'find / -name libnss3.so' but this returned no results. This system worked previously until a yum update was ran (and crashed). – Tom Whitfield Jul 6 '18 at 14:06
  • You can compile Python from source (takes about 5 mins), copy the compiled libpython2.7.so.1.0 from selected prefix to /usr/lib64 and reinstall the python dist package with yum. Thing is, it looks like libpython2.7 is not the only lib you're missing, if yum will require more libs, you can end up in compiling a bunch of libs from source in order to make yum usable again. But at least try compiling this one, maybe it will already suffice. – hoefling Jul 6 '18 at 15:23
  • If the find command didn't locate it then it's not there which is your issue. The easiest solution is to build it from source. – Nasir Riley Jul 6 '18 at 15:33
  • You mentioned the date in the Python interpreter (Jun 18 2018) is when everything stopped working. Did someone attempt to upgrade the system's Python version manually? I do not see that Redhat/CentOS offers Python v2.7.15 as their current Python version is pinned to 2.7.5. Fixing that would require getting the system provided Python back onto the server. Since you want to avoid rebuilding, you could mount the disk on a working CentOS machine, use yum --installroot=/where/you/mounted/your/disk and make sure all the proper Python packages are put back in place. – GracefulRestart Jul 6 '18 at 22:38

Usually, when I have a shared libraries issue, I use yum provides to install those. For example:

$ sudo yum provides libpython2.7.so.1.0
[sudo] password
Loaded plugins: nvidia
python-libs-2.7.5-68.el7.i686 : Runtime libraries for Python
Repo        : base
Matched from:
Provides    : libpython2.7.so.1.0 

So, to be able to do that, I suggest I remove yum and reinstall it using rpm package:

$ sudo rpm -e yum

#download yum.rpm
$ sudo rpm -ivh yum.rpm

You can download yum rpm package from here. You might also need to remove packages linked to yum like yum-utils...

| 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.