解决执行yum-complete-transaction命令时提示yum.Errors.RepoError, e错误问题

问题

更新Jenkins时系统卡住,就Ctrl+C强制取消了本次安装,但是yum的本次事务仍然存在,重新执行安装命令会显示以下内容

正在解决依赖关系
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).

按照提示执行yum-complete-transaction --cleanup-only会报以下错误

[root@localhost ~]# yum-complete-transaction --cleanup-only
  File "/usr/sbin/yum-complete-transaction", line 146
    except yum.Errors.RepoError, e:
                               ^
SyntaxError: invalid syntax

原因

yum-complete-transaction命令本质是一个python脚本,依赖python2,由于系统中存在python2python3,默认执行python命令会执行python3

[root@localhost ~]# python -V
Python 3.9.9

解决

修改yum-complete-transaction中的python依赖指向

[root@localhost ~]# vim /usr/sbin/yum-complete-transaction

#!/usr/bin/python -tt

................

import logging
import os
import os.path

#!/usr/bin/python -tt修改为#!/usr/bin/python2 -tt

保存后再次执行命令即可

[root@localhost ~]# yum-complete-transaction --cleanup-only
已加载插件:fastestmirror, product-id, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
Cleaning up unfinished transaction journals
Cleaning up 2023-05-10.11:18.25
[root@localhost ~]# yum history redo last
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Repeating transaction 36, from Wed May 10 11:38:50 2023
    安装 jenkins-2.332.3-1.1.noarch @jenkins
Loading mirror speeds from cached hostfile
软件包 jenkins-2.332.3-1.1.noarch 已安装并且是最新版本
history redo

参考

except yum.Errors.RepoError, e:_Doooooing的博客-CSDN博客[1]

参考资料

[1]

except yum.Errors.RepoError, e:_Doooooing的博客-CSDN博客: https://blog.csdn.net/qxk5055/article/details/109183444


原文始发于微信公众号(程序员段宝):解决执行yum-complete-transaction命令时提示yum.Errors.RepoError, e错误问题

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/235099.html

(0)
小半的头像小半

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!