zoukankan      html  css  js  c++  java
  • linux配置docker报错:ImportError: No module named yum

      如题,安装docker后配置仓库报错:

    [root@centos ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    Traceback (most recent call last):
      File "/usr/bin/yum-config-manager", line 6, in <module>
        import yum
    ImportError: No module named yum

      

      按提示看了yum-config-manage文件:

    [root@centos ~]# vi /usr/bin/yum-config-manager
    
    #!/usr/bin/python -tt
    
    import os, os.path
    import sys
    import re
    import yum
    sys.path.insert(0,'/usr/share/yum-cli')
    from utils import YumUtilBase
    import logging
    import fnmatch
    
    from iniparse import INIConfig

      这里的python并未指定版本,看看系统的版本

    [root@centos ~]# python -V
    Python 2.7.10

      实际python指向了2.7版本。而yum的python版本呢?

    [root@centos ~]# vi /usr/bin/yum
    
    #!/usr/bin/python2.6
    import sys
    try:
        import yum
    except ImportError:
        print >> sys.stderr, """
    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

      所以现在很清楚了,用yum执行config命令时,yum本身的python是2.6版本的,而执行的config却指向2.7,所以报错了。

      怎么办?要么改yum的python版本,要么改config的,试试修改config

    [root@centos ~]# vi /usr/bin/yum-config-manager
    
    #!/usr/bin/python2.6 -tt

      再次配置docker仓库,没有再报错:

    [root@centos ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    Loaded plugins: fastestmirror
    adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
    grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
    docker-ce.repo                                                                                                                                  | 2.4 kB     00:00     
    repo saved to /etc/yum.repos.d/docker-ce.repo
  • 相关阅读:
    LeetCode周赛#206
    CET-6备考丨词组、佳句积累
    界面设计9.24第一次课
    图像超分辨率重建
    OpenGL和计算机图形学初步认识
    OpenGL装gult库
    安装java
    vs2019配置Opengl
    最长上升子序列(最长递增子序列)LIS
    c++科学计数法 、long long的范围
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/12081802.html
Copyright © 2011-2022 走看看