突然关闭后,anaconda-navigator无法运行

时间:2019-02-27 10:32:52

标签: python utf-8 anaconda

过去几天我一直在运行anaconda-navigator。我的系统突然关闭了一天。之后,当我运行anaconda-navigator时,它显示以下错误

dstlab2@dstlab2-Veriton-M200-H81:~$ anaconda-navigator
    Traceback (most recent call last):
      File "/home/dstlab2/anaconda3/bin/anaconda-navigator", line 11, in <module>
        sys.exit(main())
      File "/home/dstlab2/anaconda3/lib/python3.7/site-packages/anaconda_navigator/app/main.py", line 99, in main
        from anaconda_navigator.utils.logs import clean_logs
      File "/home/dstlab2/anaconda3/lib/python3.7/site-packages/anaconda_navigator/utils/logs.py", line 18, in <module>
        from anaconda_navigator.config import (LOG_FILENAME, LOG_FOLDER,
      File "/home/dstlab2/anaconda3/lib/python3.7/site-packages/anaconda_navigator/config/__init__.py", line 27, in <module>
        from anaconda_navigator.config.main import CONF
      File "/home/dstlab2/anaconda3/lib/python3.7/site-packages/anaconda_navigator/config/main.py", line 71, in <module>
        raw_mode=True,
      File "/home/dstlab2/anaconda3/lib/python3.7/site-packages/anaconda_navigator/config/user.py", line 221, in __init__
        self.load_from_ini()
      File "/home/dstlab2/anaconda3/lib/python3.7/site-packages/anaconda_navigator/config/user.py", line 279, in load_from_ini
        self.read(self.filename(), encoding='utf-8')
      File "/home/dstlab2/anaconda3/lib/python3.7/configparser.py", line 696, in read
        self._read(fp, filename)
      File "/home/dstlab2/anaconda3/lib/python3.7/configparser.py", line 1014, in _read
        for lineno, line in enumerate(fp, start=1):
      File "/home/dstlab2/anaconda3/lib/python3.7/codecs.py", line 322, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf2 in position 378: invalid continuation byte

谁能帮助我正确设置事情?

1 个答案:

答案 0 :(得分:0)

看起来好像蟒蛇导航器使用的配置文件已损坏。该文件可能存在于$HOME/.anaconda文件夹中;它可能具有.ini扩展名。

如果您可以识别文件,则可以尝试替换引起问题的字节(首先制作文件的备份副本):

>>> with open('config.ini', 'rb+') as f:
...     data = f.read()
...     data = data.replace(b'\xf2', b'')
...     assert data
...     f.seek(0)
...     f.write(data)
... 
0
171

请注意,可能有多个字节。

文件被截断或损坏的可能性很大,以至于需要完全删除或替换。