No module named yum
CentOS のデフォルトの Python のバージョンは 2.6。
他の環境が 2.7 であることもあって、あげようとがんばっていたら、以下のようなエラーが、、、。
[*****@***** Python-2.7.5]$ sudo yum search php
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 (default, Jun 27 2014, 22:53:59)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
yum が見つからないんだって。
久しぶりに、「ガチでミスったかも」って思った。
そんなこと言われても対応もできないって思いつつ、
which yum
やると、きちんとパスが返ってきていたので、生きていることは確認。
こういうときに先人は偉大だ。
たしかに、そもそも yum のソースを見てみると、普通に python で動いている、ということは python のバージョンに依存していたわけだ。
sudo vi /usr/bin/yum
(具体的な場所は人によって違う可能性もあるので、きちんと which yum して場所を知っておいてからやった方がよい)
さいわい、sudo ln -sf する前にきちんと python 2.6 を避難させておいたので、そちらの PATH でソースの冒頭の python のパスを置き換えた。
#!/usr/bin/python
-> #!/usr/bin/python2.6
これで yum 復活。