redhat6.6 yum命令报错No module named sqlitecachec

报错信息:

[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 "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 55, in <module>
    import rpmsack
  File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 38, in <module>
    import yum.depsolve
  File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 30, in <module>
    from transactioninfo import TransactionMember
  File "/usr/lib/python2.6/site-packages/yum/transactioninfo.py", line 32, in <module>
    from sqlitesack import YumAvailablePackageSqlite
  File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 26, in <module>
    import yumRepo
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 34, in <module>
    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的问题就解决了。

 

 

 

### RedHat Yum 错误解决方案 对于RedHat系统中的`yum`命令出现问题的情况,可以采取一系列措施来排查并解决问题。 #### 1. 清理Yum缓存 有时由于缓存文件损坏或过期可能导致`yum`操作失败。可以通过清理缓存尝试修复: ```bash sudo yum clean all ``` 此命令会清除所有类型的缓存数据,包括元数据和软件包文件[^4]。 #### 2. 更新Yum及其插件 保持`yum`及相关组件处于最新状态有助于减少兼容性和性能方面的问题: ```bash sudo yum update yum* ``` 这一步骤能够确保正在使用的版本是最新的稳定版。 #### 3. 检查配置文件语法正确性 如果遇到特定于某个仓库的错误,则可能是对应的`.repo`文件存在格式上的问题。应仔细核对位于`/etc/yum.repos.d/`下的各个配置文件的内容是否遵循标准规范[^1]。 #### 4. 解决依赖关系冲突 当安装过程中报告缺少必要的库时(如libicu),可以根据提示通过相应的包管理器进行安装: ```bash sudo yum install libicu-devel ``` 上述指令适用于解决因缺失开发头文件而导致编译类工具无法正常工作的场景[^3]。 #### 5. 处理网络连接异常 部分情况下,外部镜像站不可达也会引发各种报错现象。此时建议切换至国内速度较快的服务商提供的镜像站点作为替代方案;另外还可以考虑搭建本地源以规避此类风险[^5]。 #### 6. 排除已知内核层面的因素 依据官方文档说明[RHEL KB # 165803],某些深层次的原因可能涉及到操作系统核心部分的工作机制变化所引起的副作用。针对这种情况需参照具体描述进一步分析处理办法[^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值