如果在这个地方,报什么,就是哪个包找不到
[root@administrator ~]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
yum报错情景1:
[root@administrator ~]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
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.6.6 (r266:84292, Mar 7 2023, 14:15:28)
[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
yum报错情况2:
No module named sqlitecachec
今天又遇到这个问题了,网上说这个sqlitecachec包在:yum-metadata-parser里,但是装了无数次还是没这个包,最后用rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --force解决,简而言之就是之前装的第一次没装上 ,然后却提示已经安装上了,最好只能使用–force强制安装安装上。
[root@administrator ~]# yum
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.6.6 (r266:84292, Mar 7 2023, 14:15:28)
[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
yum报错情况3:
这是因为缺少依赖。
[root@administrator ~]# rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm
error: Failed dependencies:
/usr/bin/python is needed by yum-3.4.3-168.el7.centos.noarch
python >= 2.4 is needed by yum-3.4.3-168.el7.centos.noarch
python(abi) = 2.7 is needed by yum-3.4.3-168.el7.centos.noarch
python-iniparse is needed by yum-3.4.3-168.el7.centos.noarch
python-sqlite is needed by yum-3.4.3-168.el7.centos.noarch
python-urlgrabber >= 3.10-8 is needed by yum-3.4.3-168.el7.centos.noarch
rpm-python is needed by yum-3.4.3-168.el7.centos.noarch
yum-metadata-parser >= 1.1.0 is needed by yum-3.4.3-168.el7.centos.noarch
yum-plugin-fastestmirror is needed by yum-3.4.3-168.el7.centos.noarch
解决方案(这是最直接的方式,其实缺哪个补哪个就行):
先卸载、删除yum残留文件后,从阿里镜像仓库下载Centos7对应系统版本的yum包,然后进行安装
卸载、删除残留文件
强制删除python已安装程序及其关联
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
删除残余python文件
whereis python |xargs rm -frv
验证删除,返回为无结果
whereis python
删除现有yum
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
删除残余yum文件
whereis yum |xargs rm -frv
下载系统版本对应的yum包
查看系统信息
[root@pg-3 lib]# hostnamectl
Static hostname: pg-3.novalocal
Icon name: computer-vm
Chassis: vm
Machine ID: 9720f29c303c44cb2616ea223625360c
Boot ID: 5eb5e965714a4c9bad3a4b4367ca912d
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.9 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.9:GA:server
Kernel: Linux 3.10.0-1160.el7.x86_64
Architecture: x86-64
[root@pg-3 lib]#
去阿里云,下载的包的版本应与系统版本号对应的一致:
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/
可以使用搜索快速找的相对应的包:
或者直接把我的这个压缩包给上传服务器也行(不收费,不要会员,不要积分):https://download.csdn.net/download/qq_61920297/89591456
总共需要下载这些包:
[root@pg-3 lib]# ls
python-2.7.5-89.el7.x86_64.rpm
python-libs-2.7.5-89.el7.x86_64.rpm
python-pycurl-7.19.0-19.el7.x86_64.rpm
python-urlgrabber-3.10-10.el7.noarch.rpm
rpm-4.11.3-45.el7.x86_64.rpm
rpm-python-4.11.3-45.el7.x86_64.rpm
yum-3.4.3-168.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
[root@pg-3 lib]#
以此类推,一步一步安装所需要的依赖。
当依赖的包无法安装时,暂时不管,先下载下来。
当所有依赖都下载后,能安装的都安装了,最后一次性安装
使用–nodeps --force参数不考虑依赖包,强制安装
[root@administrator ~]# rpm -ivh *.rpm --nodeps --force
Preparing... ################################# [100%]
Updating / installing...
1:rpm-4.11.3-45.el7 ################################# [ 25%]
2:rpm-python-4.11.3-45.el7 ################################# [ 50%]
3:yum-plugin-fastestmirror-1.1.31-5################################# [ 75%]
4:yum-3.4.3-168.el7.centos ################################# [100%]
最后发现,至少能启动了:
[root@pg-3 lib]# yum
Configuration file /etc/yum/pluginconf.d/product-id.conf not found
Unable to find configuration file for plugin product-id
Configuration file /etc/yum/pluginconf.d/search-disabled-repos.conf not found
Unable to find configuration file for plugin search-disabled-repos
Configuration file /etc/yum/pluginconf.d/subscription-manager.conf not found
Unable to find configuration file for plugin subscription-manager
Loaded plugins: fastestmirror
You need to give some command
Usage: yum [options] COMMAND
List of Commands:
check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade downgrade a package
erase Remove a package or packages from your system
fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots.
groups Display, or use, the groups information
help Display a helpful usage message
history Display, or use, the transaction history
info Display details about a package or group of packages
install Install a package or packages on your system
list List a package or groups of packages
load-transaction load a saved transaction from filename
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
repo-pkgs Treat a repo. as a group of packages, so we can install/remove all of them
repolist Display the configured software repositories
search Search package details for the given string
shell Run an interactive yum shell
swap Simple way to swap packages, instead of using shell
update Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade Update packages taking obsoletes into account
version Display a version for the machine and/or available repos.
Options:
-h, --help show this help message and exit
-t, --tolerant be tolerant of errors
-C, --cacheonly run entirely from system cache, don't update cache
-c [config file], --config=[config file]
config file location
-R [minutes], --randomwait=[minutes]
maximum command wait time
-d [debug level], --debuglevel=[debug level]
debugging output level
--showduplicates show duplicates, in repos, in list/search commands
-e [error level], --errorlevel=[error level]
error output level
--rpmverbosity=[debug level name]
debugging output level for rpm
-q, --quiet quiet operation
-v, --verbose verbose operation
-y, --assumeyes answer yes for all questions
--assumeno answer no for all questions
--version show Yum version and exit
--installroot=[path] set install root
--enablerepo=[repo] enable one or more repositories (wildcards allowed)
--disablerepo=[repo] disable one or more repositories (wildcards allowed)
-x [package], --exclude=[package]
exclude package(s) by name or glob
--disableexcludes=[repo]
disable exclude from main, for a repo or for
everything
--disableincludes=[repo]
disable includepkgs for a repo or for everything
--obsoletes enable obsoletes processing during updates
--noplugins disable Yum plugins
--nogpgcheck disable gpg signature checking
--disableplugin=[plugin]
disable plugins by name
--enableplugin=[plugin]
enable plugins by name
--skip-broken skip packages with depsolving problems
--color=COLOR control whether color is used
--releasever=RELEASEVER
set value of $releasever in yum config and repo files
--downloadonly don't update, just download
--downloaddir=DLDIR specifies an alternate directory to store packages
--setopt=SETOPTS set arbitrary config and repo options
--bugfix Include bugfix relevant packages, in updates
--security Include security relevant packages, in updates
--advisory=ADVS, --advisories=ADVS
Include packages needed to fix the given advisory, in
updates
--bzs=BZS Include packages needed to fix the given BZ, in
updates
--cves=CVES Include packages needed to fix the given CVE, in
updates
--sec-severity=SEVS, --secseverity=SEVS
Include security relevant packages matching the
severity, in updates
Plugin Options:
[root@pg-3 lib]#