do-release-upgrade中python的unicodedecodeerror解决办法
更新:最后发现错误的是我没安装过的包,最后还是屏蔽了Tsinghua的源解决了,这就很尴尬了
建议先尝试一下删除第三方源
错误出现在17.10升级到18.04的过程中,错误代码是
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Traceback (most recent call last): File "/tmp/ubuntu-release-upgrader-dsz1my1q/bionic", line 8, in <module> sys.exit(main()) File "/tmp/ubuntu-release-upgrader-dsz1my1q/DistUpgrade/DistUpgradeMain.py", line 238, in main if app.run(): File "/tmp/ubuntu-release-upgrader-dsz1my1q/DistUpgrade/DistUpgradeController.py", line 2053, in run return self.fullUpgrade() File "/tmp/ubuntu-release-upgrader-dsz1my1q/DistUpgrade/DistUpgradeController.py", line 1890, in fullUpgrade if not self.doPostInitialUpdate(): File "/tmp/ubuntu-release-upgrader-dsz1my1q/DistUpgrade/DistUpgradeController.py", line 957, in doPostInitialUpdate self.tasks = self.cache.installedTasks File "/tmp/ubuntu-release-upgrader-dsz1my1q/DistUpgrade/DistUpgradeCache.py", line 825, in installedTasks for line in pkg._pcache._records.record.split("\n"): UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 625: invalid start byte |
根据上文提示可定位到出错点在/tmp/ubuntu-release-upgrader-dsz1my1q/DistUpgrade/DistUpgradeCache.py的825行
打开对应文件找到相应行,在其上必经处添加
1 |
logging.debug("%s \n" % pkg) |
使其输出错误的pkg
以我为例,我定位的825行出错点位于函数installedTasks(
1 |
for pkg in self: |
后面添加了
1 |
logging.debug("%s \n" % pkg) |
随后,运行该升级包,最后执行的bionic要根据要升级的版本变化
1 |
/tmp/ubuntu-release-upgrader-dsz1my1q/bionic |
依然报错,但现在我们就可以去日志文件查看刚刚添加命令的输出内容。
在我的问题中,日志文件位于/var/log/