记一次 阿里云 Alibaba Cloud Linux release 3(centOS8)误删 python3 导致 yum无法使用 修复过程
因centOS8自带了python3.6,由于需要3.8+的环境,装不上去,于是把python3卸载了,结果导致yum无法使用了。
以下是最终的修复方案:
(一天后)网上一篇文章找到的思路,到同样环境的linux机器上去到yum的所有依赖包来覆盖安装
https://blog.csdn.net/weixin_43846408/article/details/131155750
到好的机器上去使用 repotrack 下载所有包(yum无法使用这个repotrack也会无法使用)
repotrack yum
参考上面的文章覆盖安装即可!
以下是修复的解决过程和思路:
到https://mirrors.aliyun.com/centos-vault/centos找系统版本,下载了关于python、yum、dnf的所有包,然后安装
tips:wget -i 下载地址.txt(每个url占一行,会把这个文件列出的url全部依次下载下来,批量安装: rpm -ivh dnf --nodeps --force)
https://zhuanlan.zhihu.com/p/495994780
https://blog.csdn.net/lddiandi/article/details/131685401
ptips:下载的包全部都带有el8.x86_64,但aliyun系统里的安装包全部都是带al8.x86_64(安装的时候心理一直打鼓,不要把系统搞坏了)
python3已经可以使用,但yum无法使用,报错:
Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/libdnf/error.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib64/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
File "
File "
File "
File "
File "
File "
ImportError: /lib64/libdnf.so.2: undefined symbol: modulemd_module_stream_v2_is_static_context
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/yum", line 57, in
from dnf.cli import main
File "/usr/lib/python3.6/site-packages/dnf/init.py", line 30, in
import dnf.base
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 29, in
import libdnf.transaction
File "/usr/lib64/python3.6/site-packages/libdnf/init.py", line 8, in
from . import error
File "/usr/lib64/python3.6/site-packages/libdnf/error.py", line 17, in
_error = swig_import_helper()
File "/usr/lib64/python3.6/site-packages/libdnf/error.py", line 16, in swig_import_helper
return importlib.import_module('_error')
File "/usr/lib64/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_error'
查询资料重新安装:libmodulemd-2.12.0-1.fc32.x86_64,然后继续报错:
Traceback (most recent call last):
File "/usr/bin/yum", line 57, in
from dnf.cli import main
File "/usr/lib/python3.6/site-packages/dnf/init.py", line 30, in
import dnf.base
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 32, in
from dnf.comps import CompsQuery
File "/usr/lib/python3.6/site-packages/dnf/comps.py", line 36, in
import libcomps
File "/usr/lib64/python3.6/site-packages/libcomps/init.py", line 1, in
from ._libpycomps import *
ImportError: libcomps.so.0: cannot open shared object file: No such file or directory
没找到资料,重新安装libcomps-0.1.16-2.el8.x86_64.rpm(死马当活马医)
yum可以执行了(大喜),但yum makecache报错:
Failed loading plugin "product-id": No module named 'subscription_manager'
Failed loading plugin "upload-profile": No module named 'subscription_manager'
Failed loading plugin "subscription-manager": No module named 'subscription_manager'
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Error: Unknown option
上述错误在上面的一篇文章(https://blog.csdn.net/lddiandi/article/details/131685401)有提到过,这下心理有底了:
找到subscription-manager相关的包,下载下来安装试试
subscription-manager-1.28.21-3.el8.x86_64.rpm 1.1 MB 2021-09-14 04:15
subscription-manager-cockpit-1.28.21-3.el8.noarch.rpm 935.6 KB 2021-09-14 04:15
subscription-manager-plugin-ostree-1.28.21-3.el8.x86_64.rpm 285.8 KB 2021-09-14 04:15
subscription-manager-rhsm-certificates-1.28.21-3.el8.x86_64.rpm
yum makecache 继续报错:
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Error: Unknown option
根据查到的资料需要将 /etc/yum.repos.d/epel.repo 文件中 failovermethod=priority 注释掉。
https://blog.csdn.net/sayyy/article/details/121490395
之前无视了上面的报错:Error: Unknown option
现在发现yum的很多命令(包括makecache、install)都无法正常执行,全部提示:Error: Unknown option
要命的是网上没找到相关的问题!
(一天后)网上一篇文章找到的思路,到同样环境的linux机器上去到yum的所有依赖包来覆盖安装
https://blog.csdn.net/weixin_43846408/article/details/131155750
到好的机器上去使用 repotrack 下载所有包(yum无法使用这个repotrack也会无法使用)
repotrack yum
参考上面的文章覆盖安装即可!