因為需要運行goagent,所以要安裝python2.7.3(原本的python版本是2.6.6)。但是在我安裝python2.7.3之後,yum不能用了。也。/usr/bin/yum把開頭( #!/usr/bin/python)改成 #!/usr/bin/python2.6。但是發現還是不能用。在命令窗里輸入:yum,它總提示:no
module name yum。然後我在google中找了很多網頁一一嘗試。
下面是我在 酷學園發表的提問,結果後來自己解決了問題。所以直接把它複製到此。
我的CentOS6.5中安裝了python2.7.6,python2.4,python2.6.6三個版本(這都是因為一直都解決不了問題,才病急亂投醫)。在/usr/bin/中,我的python====》/ust/local/bin/python2.7。/usr/bin/yum的第一行是#!/usr/bin/python2.4。但是當我敲入命令yum時,會提示錯誤,如下:
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.4
(#1, May 3 2014, 20:42:29)
[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需要的rpm中
python-2.6.6-51.el6.x86_64.rpm
python-devel-2.6.6-51.el6.x86_64.rpm
python-iniparse-0.3.1-2.1.el6.noarch.rpm
python-libs-2.6.6-51.el6.x86_64.rpm
python-pycurl-7.19.0-8.el6.x86_64.rpm
python-urlgrabber-3.9.1-9.el6.noarch.rpm
rpm-python-4.8.0-37.el6.x86_64.rpm
yum-3.2.29-40.el6.centos.noarch.rpm
我還未安裝了python-urlgrabber-3.9.1-9.el6.noarch.rpm,python-pycurl-7.19.0-8.el6.x86_64.rpm,rpm-python-4.8.0-37.el6.x86_64.rpm。之前我是rpm
-Uvh *.rpm,所以出現的錯誤太多,不知具體在哪。
當我每次輸入yum時會提示no
module name yum這種方式檢測yum是否可行是錯誤的。應該進入python2.6,然後輸入import
yum,這樣一來,缺少了哪些包,它也會提示,例如:
==============分界線=======
import
yum
Traceback
(most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 52, in
<module>
import config
File "/usr/lib/python2.6/site-packages/yum/config.py", line 30, in
<module>
from parser import ConfigPreProcessor, varReplace
File "/usr/lib/python2.6/site-packages/yum/parser.py", line 4, in
<module>
import urlgrabber
ImportError:
No module named urlgrabber
==============分界線===========
上面提示錯誤:No
module named urlgrabber
所以我就只安裝
rpm -Uvh python-urlgrabber-3.9.1-9.el6.noarch.rpm
python-pycurl-7.19.0-8.el6.x86_64.rpm(python-pycurl是urlgrabber的依賴包)。安裝後,進入python2.6,輸入import
yum,就可以了。
yum no module name rpm/yum(CentOs6.5)