修复 yum 坏掉 报错There was a problem importing one of the Python modules 教程

Posted 闭关苦炼内功

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修复 yum 坏掉 报错There was a problem importing one of the Python modules 教程相关的知识,希望对你有一定的参考价值。

有个兄弟把系统环境 yum 搞坏了,帮忙修复一下,特此记录

fix_env_2022-12-08-171615.md

1. issue : yum not in use

[root@wm-c7-ctfd-1 /]# yum repolist
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named sqlitecachec

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, Oct 14 2020, 14:56:59)
[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


[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# python -V
Python 2.7.5
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# ll /usr/bin/python*
lrwxrwxrwx 1 root root    18 Dec  8 16:40 /usr/bin/python -> /usr/bin/python2.7
lrwxrwxrwx 1 root root     9 Nov 13  2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 68600 Oct 14  2020 /usr/bin/python2.7
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# python
Python 2.7.5 (default, Oct 14 2020, 14:56:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 62, in <module>
    import rpmsack
  File "/usr/lib/python2.7/site-packages/yum/rpmsack.py", line 38, in <module>
    import yum.depsolve
  File "/usr/lib/python2.7/site-packages/yum/depsolve.py", line 30, in <module>
    from transactioninfo import TransactionMember
  File "/usr/lib/python2.7/site-packages/yum/transactioninfo.py", line 32, in <module>
    from sqlitesack import YumAvailablePackageSqlite
  File "/usr/lib/python2.7/site-packages/yum/sqlitesack.py", line 26, in <module>
    import yumRepo
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 35, in <module>
    import sqlitecachec
ImportError: No module named sqlitecachec
>>>
>>>
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# rpm -qa|grep yum
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
yum-3.4.3-168.el7.centos.noarch
[root@wm-c7-ctfd-1 /]# exit

2. well normal environment, yum

[root@c7-test-1 /]# rpm -qa|grep yum
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
yum-utils-1.1.31-54.el7_8.noarch
yum-metadata-parser-1.1.4-10.el7.aarch64
yum-3.4.3-168.el7.centos.noarch
yum-plugin-ovl-1.1.31-54.el7_8.noarch
[root@c7-test-1 /]#

3. issue : download rpm’s arch

[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# ll /opt/software/
total 1540
-rw-r--r-- 1 root root   98100 Dec  8 10:17 python-2.7.5-89.el7.x86_64.rpm
-rw-r--r-- 1 root root   39800 Dec  8 10:17 python-iniparse-0.4-9.el7.noarch.rpm
-rw-r--r-- 1 root root 1298856 Dec  8 10:17 yum-3.4.3-168.el7.centos.noarch.rpm
-rw-r--r-- 1 root root   67120 Dec  8 15:45 yum-cron-3.4.3-168.el7.centos.noarch.rpm
-rw-r--r-- 1 root root   28348 Dec  8 15:46 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r-- 1 root root   35216 Dec  8 10:20 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
[root@wm-c7-ctfd-1 /]#

4. check os arch

[root@wm-c7-ctfd-1 /]# arch
aarch64
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# cat /etc/system-release
CentOS Linux release 7.9.2009 (AltArch)
[root@wm-c7-ctfd-1 /]#

5. download correct yum’s rpms

[root@wm-c7-ctfd-1 /]# cd /opt/software/
[root@wm-c7-ctfd-1 software]# mkdir old;mv ./* old
mv: cannot move './old' to a subdirectory of itself, 'old/old'
[root@wm-c7-ctfd-1 software]# ll
total 0
drwxr-xr-x 2 root root 289 Dec  8 16:53 old
[root@wm-c7-ctfd-1 software]#
[root@wm-c7-ctfd-1 software]#
[root@wm-c7-ctfd-1 software]#
[root@wm-c7-ctfd-1 software]# vim yum-rpm.txt
[root@wm-c7-ctfd-1 software]#
[root@wm-c7-ctfd-1 software]# cat yum-rpm.txt
https://repo.huaweicloud.com/centos-altarch/7.9.2009/os/aarch64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
https://repo.huaweicloud.com/centos-altarch/7.9.2009/os/aarch64/Packages/yum-metadata-parser-1.1.4-10.el7.aarch64.rpm
https://repo.huaweicloud.com/centos-altarch/7.9.2009/os/aarch64/Packages/yum-plugin-ovl-1.1.31-54.el7_8.noarch.rpm
[root@wm-c7-ctfd-1 software]#
[root@wm-c7-ctfd-1 software]# wget -i yum-rpm.txt
bash: wget: command not found
[root@wm-c7-ctfd-1 software]#
[root@wm-c7-ctfd-1 software]#
  • host machine downloading rpms
[root@oe85 ~]# mkdir /tmp/11
[root@oe85 ~]# cd /tmp/11/
[root@oe85 11]# vim file.txt
[root@oe85 11]#
[root@oe85 11]# wget -i file.txt
--2022-12-08 16:54:55--  https://repo.huaweicloud.com/centos-altarch/7.9.2009/os/aarch64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
Resolving repo.huaweicloud.com (repo.huaweicloud.com)... 157.255.138.36, 157.255.138.41, 157.255.138.38, ...
Connecting to repo.huaweicloud.com (repo.huaweicloud.com)|157.255.138.36|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 124852 (122K) [application/x-redhat-package-manager]
Saving to: ‘yum-utils-1.1.31-54.el7_8.noarch.rpm’

yum-utils-1.1.31-54.el7_8.noarch.r 100%[=============================================================>] 121.93K  --.-KB/s    in 0.06s

2022-12-08 16:54:56 (1.97 MB/s) - ‘yum-utils-1.1.31-54.el7_8.noarch.rpm’ saved [124852/124852]

--2022-12-08 16:54:56--  https://repo.huaweicloud.com/centos-altarch/7.9.2009/os/aarch64/Packages/yum-metadata-parser-1.1.4-10.el7.aarch64.rpm
Reusing existing connection to repo.huaweicloud.com:443.
HTTP request sent, awaiting response... 200 OK
Length: 27456 (27K) [application/x-redhat-package-manager]
Saving to: ‘yum-metadata-parser-1.1.4-10.el7.aarch64.rpm’

yum-metadata-parser-1.1.4-10.el7.a 100%[=============================================================>]  26.81K  --.-KB/s    in 0.02s

2022-12-08 16:54:56 (1.26 MB/s) - ‘yum-metadata-parser-1.1.4-10.el7.aarch64.rpm’ saved [27456/27456]

--2022-12-08 16:54:56--  https://repo.huaweicloud.com/centos-altarch/7.9.2009/os/aarch64/Packages/yum-plugin-ovl-1.1.31-54.el7_8.noarch.rpm
Reusing existing connection to repo.huaweicloud.com:443.
HTTP request sent, awaiting response... 200 OK
Length: 28564 (28K) [application/x-redhat-package-manager]
Saving to: ‘yum-plugin-ovl-1.1.31-54.el7_8.noarch.rpm’

yum-plugin-ovl-1.1.31-54.el7_8.noa 100%[=============================================================>]  27.89K  --.-KB/s    in 0.002s

2022-12-08 16:54:56 (16.1 MB/s) - ‘yum-plugin-ovl-1.1.31-54.el7_8.noarch.rpm’ saved [28564/28564]

FINISHED --2022-12-08 16:54:56--
Total wall clock time: 1.4s
Downloaded: 3 files, 177K in 0.08s (2.08 MB/s)
[root@oe85 11]#
[root@oe85 11]#
  • copy to ctfd machine
[root@oe85 11]# pwd
/tmp/11
[root@oe85 11]#
[root@oe85 11]# docker cp /tmp/11 678:/opt/software/
[root@oe85 11]# docker exec -it 678 bash
[root@wm-c7-ctfd-1 /]# ll /opt/software/
total 4
drwxr-xr-x 2 root root 167 Dec  8 16:54 11
drwxr-xr-x 2 root root 289 Dec  8 16:53 old
-rw-r--r-- 1 root root 343 Dec  8 16:53 yum-rpm.txt
[root@wm-c7-ctfd-1 /]#
[root@wm-c7-ctfd-1 /]# ll /opt/software/11/
total 184
-rw-r--r-- 1 root root    344 Dec  8 16:54 file.txt
-rw-r--r-- 1 root root  27456 Sep  8  2017 yum-metadata-parser-1.1.4-10.el7.aarch64.rpm
-rw-r--r-- 1 root root  28564 May 14  2020 yum-plugin-ovl-1.1.31-54.el7_8.noarch.rpm
-rw-r--r-- 1 root root 124852 May 14  2020 yum-utils-1.1.31-54.el7_8.noarch.rpm
[root@wm-c7-ctfd-1 /]#

6. rpm setup deps

[root@wm-c7-ctfd-1 /]# cd /opt/software/11/
[root@wm-c7-ctfd-1 11]# rpm -ivh *.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-utils-1.1.31-54.el7_8        ################################# [ 33%]
   2:yum-plugin-ovl-1.1.31-54.el7_8   ################################# [ 67%]
   3:yum-metadata-parser-1.1.4-10.el7 ################################# [100%]
[root@wm-c7-ctfd-1 11]#
[root@wm-c7-ctfd-1 11]# rpm -qa|grep yum
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
yum-utils-1.1.31-54.el7_8.noarch
yum-metadata-parser-1.1.4-10.el7.aarch64
yum-3.4.3-168.el7.centos.noarch
yum-plugin-ovl-1.1.31-54.el7_8.noarch
[root@wm-c7-ctfd-1 11]#


[root@wm-c7-ctfd-1 ~]# ll /etc/yum.repos.d/
total 40
-rw-r--r-- 1 root root  1918 Oct 23  2020 CentOS-Base.repo
-rw-r--r-- 1 root root  1370 Oct 23  2020 CentOS-CR.repo
-rw-r--r-- 1 root root   709 Oct 23  2020 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root   690 Oct 23  2020 CentOS-Media.repo
-rw-r--r-- 1 root root  1573 Oct 23  2020 CentOS-Sources.repo
-rw-r--r-- 1 root root 11665 Oct 23  2020 CentOS-Vault.repo
-rw-r--r-- 1 root root   802 Oct 23  2020 CentOS-aarch64-kernel.repo
-rw-r--r-- 1 root root   351 Oct 23  2020 CentOS-fasttrack.repo
drwxr-xr-x 2 root root   221 Dec  8 16:09 c7-repo
drwxr-xr-x 2 root root   252 Dec  8 16:06 old
[root@wm-c7-ctfd-1 ~]#

[root@wm-c7-ctfd-1 ~]# yum clean all;yum makecache

[root@wm-c7-ctfd-1 11]# yum repolist
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirror.nju.edu.cn
 * extras: mirror.nju.edu.cn
 * updates: mirror.nju.edu.cn
base                                                                                                              | 3.6 kB  00:00:00
extras                                                                                                            | 2.9 kB  00:00:01
updates                                                                                                           | 2.9 kB  00:00:01
repo id                                                          repo name                                                         status
base/7/aarch64                                                   CentOS-7 - Base                                                   7629
extras/7/aarch64                                                 CentOS-7 - Extras                                                  512
updates/7/aarch64                                                CentOS-7 - Updates                                                3158
repolist: 11299
[root@wm-c7-ctfd-1 11]#
[root@wm-c7-ctfd-1 11]#

以上是关于修复 yum 坏掉 报错There was a problem importing one of the Python modules 教程的主要内容,如果未能解决你的问题,请参考以下文章

Shiro报错-[org.apache.shiro.mgt.AbstractRememberMeManager] - There was a failure while trying to retri

Matlab解决使用Mex 报错There was a problem creating the mex file for Real Time Execution ,Please ensure y

使用pip报错:Could not fetch URL https://pypi.org/simple/: There was a problem confirming the ssl certi

使用pip报错:Could not fetch URL https://pypi.org/simple/: There was a problem confirming the ssl certi

使用pip报错:Could not fetch URL https://pypi.org/simple/: There was a problem confirming the ssl certi

Xcode真机调试中"There was an internal API error"错误解决方法