yum 安裝

yum 安裝原本是個很簡單的事情,只是網上的教程通常不全,每次裝每次都踩坑,必須作個筆記了。html

 

具體安裝過程請自行百度,一堆,耐心點就好。python

 

異常記錄

1. 明明按教程一步步安裝完了,仍然報錯

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.12 (default, Oct  1 2019, 01:09:22) 
[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 依賴 自帶的 python,因此更新版本以後要把 yum 的配置改回老版本。centos

 

解決辦法ide

第一步: 查看 python 版本oop

[root@hadoop10 yum]# whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/share/man/man1/python.1.gz

我 重裝了 python,把 2.6 升級到了 2.7ui

 

第二步:修改 yum 的 python 版本this

[root@hadoop10 yum]# which yum
/usr/bin/yum
[root@hadoop10 yum]# vi /usr/bin/yum

#!/usr/bin/python2.6
import sys
try:
    import yum
except ImportError:

把 yum 第一行 python 改爲 python2.6url

 

2. 報錯以下

[root@hadoop10 site-packages]# yum makecache
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Determining fastest mirrors
http://mirrors.163.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.163.com'"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

解決辦法spa

[root@hadoop10 site-packages]# cd /etc/yum.repos.d/
[root@hadoop10 yum.repos.d]# ls
CentOS-Base-163.repo  CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
[root@hadoop10 yum.repos.d]# vi CentOS-Base.repo 

把 全部的 $releasever 換成 6.net

 

 

 

參考資料:

https://blog.csdn.net/yqj234/article/details/83374665  安裝

http://www.mamicode.com/info-detail-2392307.html  安裝

http://blog.chinaunix.net/uid-9881170-id-5749784.html    異常 2

https://blog.csdn.net/u013615806/article/details/51043898  異常 2

相關文章
相關標籤/搜索