如題,安裝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