記一次linux7.3yum源失效問題
由于手賤升級python 導致yum 失效
報錯
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.5 (default, Nov 2 2021, 21:34:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

由于又手賤吧python 刪了又裝,根據CSDN 各種帖子都沒整好
經過多種操作最終解決問題,操作開始
1.先看系統版本

[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)
2.根據系統版本下載對應python包
官網地址:https://www.python.org/downloads/
找一臺跟自己系統版本一樣的linux 查看python版本

[root@localhost ~]# python -V
Python 2.7.5
3.卸載當前系統python,yum依賴
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
whereis python |xargs rm -frv
whereis python
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv
4.重新下載安裝對應系統的python版本
4.1.linux下安裝
--- 安裝依賴包
# cd /usr/local
# wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
# tar -xzvf Python-2.7.5.tgz
# cd Python-2.7.5
# ./configure --prefix=/usr/local/Python2.7.5 --enable-shared -enable-unicode=ucs4
# make
# make install
# python -V
4.2.python解釋器指向python2.7.5
# which python
# cd /usr/bin
# rm python
# ln -s /usr/local/Python2.7.5/bin/python python
# python -V --執行報錯
4.3.解決python -V執行報錯
# cd /etc/ld.so.conf.d/
# echo "/usr/local/Python2.7.5/lib" > python2.7.conf
# ldconfig
# python -V
5.找一臺yum好的服務器,注意是好的!
找一臺yum功能完好的服務器, 系統版本和壞的一致,
沒有就自己去搭建一臺和自己系統版本一樣的虛擬機
5.1.輸入命令查找 site-packages 包路徑

[root@localhost ~]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages']
>>>
[root@localhost ~]#
python
import sys
print sys.path
輸入 ctrl+D 退出


5.2.將/usr/lib64/python2.7/site-packages’, ‘/usr/lib/python2.7/site-packages’ 兩個路徑下的檔案全部打包下載

5.3.找到/usr/share/yum-cli 將這個目錄下的檔案全部下載

5.4.打包下載后,轉回,我們yum壞的那臺服務器,找到路徑 /usr/local/Python2.7.5/lib/python2.7/site-packages

這里可以看到我們是對應目錄是空的
將剛剛打包下載的site-packages 檔案全部上傳到這

5.5.將剛剛下載的/usr/share/yum-cli 上傳到 /usr/share/yum-cli

查看/usr/share 目錄 看看 有沒有yum-cli 目錄, 如果沒有那就創建一個,將好的那臺服務器的檔案傳過來, 如果有,那就吧里面檔案全部刪掉, 在上傳好的那臺服務器
6.最后 執行yum 完美解決, 最好的解決辦法就是找一臺好的,將他python 目錄下的 site-packages 和/usr/share/yum-cli 檔案直接復制到掛的那臺
別整什么下載各種插件,rpm安裝,都是假的,全都沒用, ctrl c ctrl v ,將好服務器的ctrl c ctrl v 到壞的比什么都強 艸

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/349764.html
標籤:其他
上一篇:寶塔+青龍+傻妞教程
