“UnicodeDecodeError: 'ascii' codec”问题解决方法

分类:CentOS运维 阅读:63206 次

问题

新装了CentOS 6.5系统,打算使用yum安装程序是出现了如下错误:

  1. Loadingmirrorspeedsfromcachedhostfile
  2. Traceback(mostrecentcalllast):
  3. File"/usr/bin/yum",line29,in<module>
  4. yummain.user_main(sys.argv[1:],exit_code=True)
  5. File"/usr/share/yum-cli/yummain.py",line285,inuser_main
  6. errcode=main(args)
  7. File"/usr/share/yum-cli/yummain.py",line136,inmain
  8. result,resultmsgs=base.doCommands()
  9. File"/usr/share/yum-cli/cli.py",line434,indoCommands
  10. self._getTs(needTsRemove)
  11. File"/usr/lib/python2.6/site-packages/yum/depsolve.py",line99,in_getTs
  12. self._getTsInfo(remove_only)
  13. File"/usr/lib/python2.6/site-packages/yum/depsolve.py",line110,in_getTsInfo
  14. pkgSack=self.pkgSack
  15. File"/usr/lib/python2.6/site-packages/yum/__init__.py",line887,in<lambda>
  16. pkgSack=property(fget=lambdaself:self._getSacks(),
  17. File"/usr/lib/python2.6/site-packages/yum/__init__.py",line669,in_getSacks
  18. self.repos.populateSack(which=repos)
  19. File"/usr/lib/python2.6/site-packages/yum/repos.py",line279,inpopulateSack
  20. self.doSetup()
  21. File"/usr/lib/python2.6/site-packages/yum/repos.py",line105,indoSetup
  22. self.ayum.plugins.run('postreposetup')
  23. File"/usr/lib/python2.6/site-packages/yum/plugins.py",line184,inrun
  24. func(conduitcls(self,self.base,conf,**kwargs))
  25. File"/usr/lib/yum-plugins/fastestmirror.py",line197,inpostreposetup_hook
  26. ifdowngrade_ftpand_len_non_ftp(repo.urls)==1:
  27. File"/usr/lib/python2.6/site-packages/yum/yumRepo.py",line699,in<lambda>
  28. urls=property(fget=lambdaself:self._geturls(),
  29. File"/usr/lib/python2.6/site-packages/yum/yumRepo.py",line696,in_geturls
  30. self._baseurlSetup()
  31. File"/usr/lib/python2.6/site-packages/yum/yumRepo.py",line648,in_baseurlSetup
  32. self.mirrorurls=self._replace_and_check_url(mirrorurls)
  33. File"/usr/lib/python2.6/site-packages/yum/yumRepo.py",line691,in_replace_and_check_url
  34. print'YumRepoError:AllmirrorURLsarenotusingftp,http[s]orfile.\nEg.%s'%misc.to_utf8(skipped)
  35. File"/usr/lib64/python2.6/codecs.py",line351,inwrite
  36. data,consumed=self.encode(object,self.errors)
  37. UnicodeDecodeError:'ascii'codeccan'tdecodebyte0xbcinposition3746:ordinalnotinrange(128)

解决方案

依次执行以下操作:

  1. cd/var/lib/rpm/
  2. rm-i__db.*
  3. yumcleanall
  4. yumhistorynew