报错信息:
[root@hsrc01 Packages]# 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, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
[root@hsrc01 Packages]# python
Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
Traceback (most recent call last):
File "
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 55, in
import rpmsack
File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 38, in
import yum.depsolve
File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 30, in
from transactioninfo import TransactionMember
File "/usr/lib/python2.6/site-packages/yum/transactioninfo.py", line 32, in
from sqlitesack import YumAvailablePackageSqlite
File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 26, in
import yumRepo
File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 34, in
import sqlitecachec
ImportError: No module named sqlitecachec
原因:删除了linux下面的python2.6以及相关的yum源依赖包,删除命令如下:
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
[root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
[root@test ~]# whereis python ##验证删除,返回无结果
找了网上很多资料,才总结下面的方法可行:
[root@hsrc01 Packages]# cd /var/lib/rpm/
[root@hsrc01 rpm]# rm -i __db.*
rm: remove regular file `__db.001'? y
rm: remove regular file `__db.002'? y
rm: remove regular file `__db.003'? y
rm: remove regular file `__db.004'? y
[root@hsrc01 rpm]# rpm --rebuilddb
[root@hsrc01 rpm]# rpm -ivh --force /media/RHEL-6.6\ Server.x86_64/Packages/yum-3.2.29-60.el6.noarch.rpm /media/RHEL-6.6\ Server.x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm --nodeps
warning: /media/RHEL-6.6 Server.x86_64/Packages/yum-3.2.29-60.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:yum-metadata-parser ########################################### [ 50%]
2:yum ########################################### [100%]
You have new mail in /var/spool/mail/root
[root@hsrc01 rpm]# whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.6-config /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
[root@hsrc01 rpm]# vi /usr/bin/yum
将 #!/usr/bin/python 修改为 #!/usr/bin/python2.6
如果是源代码安装的,默认路径是/usr/local/bin/python2.6,做个软链接即可
rm -rf /usr/bin/python
ln -s /usr/local/bin/python2.6 /usr/bin/python
[root@hsrc01 rpm]# yum
Plugin "aliases" can't be imported
Plugin "product-id" can't be imported
Plugin "subscription-manager" can't be imported
Loaded plugins: downloadonly, refresh-packagekit, security, verify
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
groupinfo Display details about a package group
groupinstall Install the packages in a group on your system
grouplist List available package groups
groupremove Remove the packages in a group from your system
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
repolist Display the configured software repositories
resolvedep Determine which package provides the given dependency
search Search package details for the given string
shell Run an interactive yum shell
update Update a package or packages on your system
update-minimal Works like update, 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
verify-all Verify packages and display data on bad verifications
verify-multilib Verify packages and display data on bad verifications
verify-rpm Verify packages and display data on bad verifications
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
--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
--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
--setopt=SETOPTS set arbitrary config and repo options
Plugin Options:
--downloadonly don't update, just download
--downloaddir=DLDIR
specifies an alternate directory to store packages
--security Include security relevant packages
--bugfixes Include bugfix relevant packages
--cve=CVE Include packages needed to fix the given CVE
--bz=BZ Include packages needed to fix the given BZ
--sec-severity=SEVERITY
Include security relevant packages, of this severity
--advisory=ADVISORY
Include packages needed to fix the given advisory
--verify-filenames=VERIFY_FILENAMES
Only verify files matching this
--verify-configuration-files=VERIFY_CONFIGURATION_FILES
Verify files tagged as configuration files
最后yum的问题就解决了。