报错场景
CentOS 7.9中执行yum
命令,出现报错:
坏的解释器:权限不够`
错误原因
原因是系统Python
版本从2.x
升级到3.x
导致的兼容性冲突。yum
文件中的Python
解释器路径为2.7
版本。
解决问题 查看系统版本 1 2 ~]# cat /etc/centos-release CentOS Linux release 7.9.2009 (Core)
下载安装包 阿里云镜像库 https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages
自行替换自己的系统版本,找到wget-1.14-18.el7_6.1.x86_64.rpm
下载即可
拷贝安装包进行安装 将下载好的wget
安装包拷贝到对应的目录,然后cd
到对应目录执行以下命令 如:拷贝到/home
下之后,执行 cd /home
,然后安装即可rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm
安装yum 卸载python 1 2 3 4 5 6 7 8 rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps whereis python |xargs rm -frv -rf whereis python
删除yum 1 2 rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps whereis yum |xargs rm -frv -rf
下载依赖包 能联网的话直接复制运行即可(注意下载路径,会下载到当前路径下),如果不能联网就自己手动下载然后拷贝到服务器上
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/lvm2-python-libs-2.02.187-6.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages//python-libs-2.7.5-89.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-aliases-1.1.31-54.el7_8.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-54.el7_8.noarch.rpm wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
安装替换依赖 1 ~]# rpm -ivh --nodeps --force *.rpm
测试 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ~]# yum 已加载插件:aliases, fastestmirror, protectbase 您需要给出命令 Usage: yum [options] COMMAND List of Commands: alias Adds or lists aliasescheck 检查 RPM 数据库问题 check-update 检查是否有可用的软件包更新 ~]# python Python 2.7.5 (default, Oct 14 2020, 14:45:30) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2 Type "help" , "copyright" , "credits" or "license" for more information. >>>
yum源处理 删除yum源 1 ~]# rm -rf /etc/yum/.repos.d/*
下载阿里云yum源 1 ~]# wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/Centos-7.repo
拷贝yum源 把下载好的Centos-7.repo
拷贝到/etc/yum.repos.d/
下,没有该文件夹就手动新建一个
清除和生成yum缓存 1 2 3 4 5 yum clean all yum makecache