最近在用linux做android开发,之前在弄输入法,把ibus替换为fcitx,之中大概是删掉了系统中的一些语言包。

当时也没在意。

后来开始用repo工具更新源码,开始报错:

Traceback (most recent call last):
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/main.py", line 532, in <module>
    _Main(sys.argv[1:])
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/main.py", line 508, in _Main
    result = repo._Run(argv) or 0
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/main.py", line 159, in _Run
    copts, cargs = cmd.OptionParser.parse_args(argv)
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/command.py", line 67, in OptionParser
    self._Options(self._optparse)
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/subcmds/sync.py", line 189, in _Options
    self.jobs = self.manifest.default.sync_j
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/manifest_xml.py", line 355, in default
    self._Load()
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/manifest_xml.py", line 423, in _Load
    self._ParseManifest(nodes)
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/manifest_xml.py", line 532, in _ParseManifest
    project = self._ParseProject(node)
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/manifest_xml.py", line 794, in _ParseProject
    relpath, worktree, gitdir, objdir = self.GetProjectPaths(name, path)
  File "/home/niyaou/work/Android源码/aosp7/.repo/repo/manifest_xml.py", line 844, in GetProjectPaths
    worktree = os.path.join(self.topdir, path).replace('\\', '/')
  File "/usr/lib/python2.7/posixpath.py", line 80, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 25: ordinal not in range(128)
niyaou@niyaou:~/



查了一下,大概是ASCII转码UTF-8的时候出错。


解决办法

找到python所在目录   

/usr/lib/python2.7/site-packages/sitecustomize.py
 
加入以下代码
import sys
sys.setdefaultencoding("utf-8")

 
搞定

Logo

更多推荐