如题,安装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