[CENTOS] What to do if yum breaks

What happened

In the environment of CentOS (6.9 this time), I often use yum, but suddenly I can't use it. Is it because of the python version? → I don't understand anymore.

I went back and forth to the reference sites, and finally it started working.

File "/usr/bin/yum", line 29, in ~ First error I get the following error and can't do anything

# yum update

Loaded plugin:fastestmirror
Loading mirror speeds from cached hostfile
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 370, in user_main
    errcode = main(args)
  ...

Coping

Fixed yum config file

text:/etc/yum/pluginconf.d/fastestmirror.conf


[main]
enabled=0

reference

http://blog.dksg.jp/2017/04/yum-update.html

No module named yum Second error The version doesn't match

↓ is a similar log (different from when it actually occurred)

# yum update
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.7.5 (r265:79063, Feb 28 2011, 21:55:45) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]

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

Coping

Specifying python to run yum

/usr/bin/before yum correction


#!/usr/bin/python
import sys
try:
    import yum
    ...

/usr/bin/After yum correction


#!/usr/bin/python2.6
import sys
try:
    import yum
    ...

reference

http://d.hatena.ne.jp/ike-dai/20110713/1310552674

Recommended Posts

What to do if yum breaks
What to do if pipreqs results in UnicodeDecodeError
What to do if you can't pipenv shell
Note: What to do if pip install fails
What to do if mod_fcgid cannot resolve UnicodeEncodeError
What to do if rails s doesn't work
What to do if pip cannot be installed
What to do if atom autocomplete-python doesn't work
What to do if Docker-sync suddenly stops working
What to do if "amazon-linux-extras" → "No module named amazon_linux_extras"
What to do if the yum command fails to set locale, defaulting to C
What to do if pip install fails in Xcode 5.1
What to do if you can't pip install mysqlclient
No module named What to do if you get'libs.resources'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
What to do if SciPy installation fails on CentOS
What to do if a UnicodeDecodeError occurs in pip
What to do if pip install fails to install dependent libraries
What to do if sys / cdefs.h does not exist
What to do if pyenv is not enabled (zsh)
What to do when Ubuntu crashes
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
What to do if the package dependency cannot be repaired
What to do with Magics install
What to do if you are addicted to Windows character code
What to do if pip gives a DistributionError in Homebrew
What to do if you get "coverage unknown" in Coveralls
What to do if you can't sort files with subscripts
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
What to do with PYTHON release?
What to do if package installation fails when deploying to heroku
What to do if `pip install matplotlib` fails on Mac
What to do if you can't log in as root
What to do if you can't use WiFi on Linux
What to do if Linux VLC can no longer rotate
What to do if pip install mysqlclient fails on MacOS
What to do to get tensorflow-gpu to work
What to do if you lose your EC2 key pair
What to do if you get a Cannot retrieve metalink for repository error in yum
What to do if Python doesn't work on Git for Windows
What to do if you can't install pyaudio with pip #Python
What to do if you get a minus zero in Python
What to do if intellisense doesn't work with Anaconda + VSCode + Tensorflow2.1
What to do if python says "fatal error:'stdio.h' file not found"
What to do if you get a UnicodeDecodeError with pip install
What to do if Insecure Platform Warning appears when running Python
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do if the inode is exhausted on EC2 Linux
What to do if you can't build your project with Maven
What to do if PyAudio cannot be installed on Python 3.7, 3.8, 3.9 on Windows
What to do if you can't use the trash in Lubuntu 18.04.
Django: What to do if TemplateDoesNotExist at / admin / after setting templates
What to do if grep: empty (sub) expression appears on Mac grep
What to do after installing Linux (Ubuntu)
Let's summarize what you want to do.
What to do if you can't find well with grep's -f option
What to do if there is a decimal in python json .dumps
What to do if you can't find PDO in Laravel or CakePHP
What to do if the Pipenv environment is corrupted by updating Homebrew
What to do if you couldn't send an email to Yahoo with Python.
What to do if you can't use scikit grid search in Python