I was uninstalling OpenSSH with the following command:

for i in $(rpm -qa | grep openssh);do sudo rpm -e $i --nodeps;done

Then for some reason, I don't know why I thought this was a good idea, I ran this command to remove python:

for i in $(rpm -qa | grep python);do sudo rpm -e $i --nodeps;done

Now when I run sudo yum update I get the following:

bash: /bin/yum: /usr/bin/python: bad interpreter: No such file or directory

First line of /bin/yum reads:


I then checked the /usr/bin directory for python

ls -lha /usr/bin | grep python

and got back nothing.

1 Answer 1


Search the web for the appropriate Python RPMs, download them manually eg. using wget or curl and install them manually using rpm -i.

From your comments I see that you have another machine with the same CentOS release, so you are lucky :). You can obtain exact information which packages to install. On that other machine, type

rpm -q -R yum

This will list all yum dependencies. For example, on an old release of CentOS I have access to, it lists the following:

config(yum) = 3.2.29-40.el6.centos
python >= 2.4
python(abi) = 2.6
python-urlgrabber >= 3.9.0-8
rpm >= 0:4.4.2
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(VersionedDependencies) <= 3.0.3-1
yum-metadata-parser >= 1.1.0
rpmlib(PayloadIsXz) <= 5.2-1

You can ignore the entries that don't have python in their name as you didn't uninstall them. You can also ignore the python(abi) entry as it's just a feature provided by python package. So what is left is:

python >= 2.4
python-urlgrabber >= 3.9.0-8

Then for each of these packages run

rpm -q <packagename>

It will give you the exact filename/version of the package installed. For example, on the machine I have rpm -q python outputs python-2.6.6-36.el6.x86_64 and rpm -q python-iniparse outputs python-iniparse-0.3.1-2.1.el6.noarch. So you have to look exactly for these filenames in CentOS repositories. You can find the addressess of the repositories in files that are located within the /etc/yum.repos.d directory.

Download these RPM files and install them.

If yum still doesn't work, it is possible that Python packages depend on each other and something is still missing. Check the following on the other machine:

rpm -qa | grep python

and install all the indicated packages on the broken machine.

  • I found python 2.7.5 rpm and was able to install it via rpm -i. I can now run python and get python 2.7.5 interpreter
    – Jono
    Jan 20, 2021 at 11:45
  • However, when I do a sudo yum update command I get the following error: Traceback (most recent call list): File "/bin/yum", line 29, in <module> yummain.user_main(sys.argv[1:], exit_code_True) File "/usr/share/yum-cli/yummain.py" line 236, in user_main errcode = main(args) File "/usr/share/yum-cli/yummain.py" line 90, in main base.getOptionsConfig(args) File "/usr/share/yum-cli/cli.py" line 161, in getOptionsConfig disabled_plugins=self.optparser._splitArg(opts.disabledplugins)) TypeError: _getConfig() takes exactly 1 argument (9 given)
    – Jono
    Jan 20, 2021 at 11:49
  • Probably you need some additional Python modules as well.
    – raj
    Jan 20, 2021 at 11:52
  • I just ran rpm -q -R yum on some old CentOS I have access to and it told me that yum depends on packages python-iniparse, python-sqlite, python-urlgrabber and rpm-python. When you uninstalled everything python-related, you probably uninstalled them, so you need to install them again.
    – raj
    Jan 20, 2021 at 11:57
  • 1
    I have another machine that is CentOS 7.9 (same as machine with issue). What command can I run to get all the .rpms needed to fix the yum issue?
    – Jono
    Jan 20, 2021 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .