解决No module named yum There was a problem importing one of the Python modules

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.9 (default, Aug 21 2024, 14:17:12) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

背景:我在原来的python版本上升级了2.7.9后,yum就不能用了,我vim /usr/bin/yum 后,修改了新的python路径(#!/usr/local/bin/python),依然不好用。

处理:查看/usr/bin/目录下

# cd /usr/bin/
 ll | grep python
  11232 Aug 10  2017 abrt-action-analyze-python
    153 Aug 19 14:11 ipython
    153 Aug 19 14:11 ipython2
   7280 Apr 13  2018 pmpython
     21 Aug 21 14:20 python -> /usr/local/bin/python  # 有问题
      9 Jun 21  2021 python2 -> python2.7
   7216 Apr 11  2018 python2.7
      7 Jun 21  2021 python2.7.5 -> python2
   1835 Apr 11  2018 python2.7-config
     16 Jun 21  2021 python2-config -> python2.7-config
     14 Jun 21  2021 python-config -> python2-config

操作如下:

rm -f python
ln -s python2 python
ll | grep python
11232 Aug 10  2017 abrt-action-analyze-python
  153 Aug 19 14:11 ipython
  153 Aug 19 14:11 ipython2
 7280 Apr 13  2018 pmpython
    7 Aug 21 14:49 python -> python2
    9 Jun 21  2021 python2 -> python2.7
 7216 Apr 11  2018 python2.7
    7 Jun 21  2021 python2.7.5 -> python2
 1835 Apr 11  2018 python2.7-config
   16 Jun 21  2021 python2-config -> python2.7-config
   14 Jun 21  2021 python-config -> python2-config

然后 ,yum命令就可以使用了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值