解决执行"yum-complete-transaction"命令时提示"except 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
,由于系统中存在python2
和python3
,默认执行python
命令会执行python3
[root@localhost ~]# python -V
Python 3.9.9
解决
修改yum-complete-transaction
中的python
依赖指向
[root@localhost ~]# vim /usr/sbin/yum-complete-transaction
#!/usr/bin/python2 -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博客
#Linux(2)#CentOS(2)文章作者:LonelyMan
版权声明:本博客所有文章除特别声明外,均采用CC BY-NC-SA 4.0 许可协议,转载请注明出处!
评论