spyder unicode decode error in startup

不羁的心 提交于 2019-12-23 03:29:20

问题


I was using spyder-ide while parsing a tumblr page with the permission of the author, and at some point everything just crashed. Even my linux system had freezed. Well, to cut to the chase now I can not start spyder, it gives me the following error after I had written spyder to my terminal:

 Traceback (most recent call last):
  File "/home/dk/anaconda3/bin/spyder", line 2, in <module>
    from spyderlib import start_app
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/start_app.py", line 13, in <module>
    from spyderlib.config import CONF
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/config.py", line 736, in <module>
    subfolder=SUBFOLDER, backup=True, raw_mode=True)
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/userconfig.py", line 215, in __init__
    self.load_from_ini()
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/userconfig.py", line 265, in load_from_ini
    self.read(self.filename(), encoding='utf-8')
  File "/home/dk/anaconda3/lib/python3.5/configparser.py", line 696, in read
    self._read(fp, filename)
  File "/home/dk/anaconda3/lib/python3.5/configparser.py", line 1012, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/home/dk/anaconda3/lib/python3.5/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: invalid continuation byte

I tried the solution here and I had received the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/spyder.py", line 107, in <module>
    from spyderlib.utils.qthelpers import qapplication
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/utils/qthelpers.py", line 24, in <module>
    from spyderlib.guiconfig import get_shortcut
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/guiconfig.py", line 22, in <module>
    from spyderlib.config import CONF
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/config.py", line 736, in <module>
    subfolder=SUBFOLDER, backup=True, raw_mode=True)
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/userconfig.py", line 215, in __init__
    self.load_from_ini()
  File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/userconfig.py", line 265, in load_from_ini
    self.read(self.filename(), encoding='utf-8')
  File "/home/dk/anaconda3/lib/python3.5/configparser.py", line 696, in read
    self._read(fp, filename)
  File "/home/dk/anaconda3/lib/python3.5/configparser.py", line 1012, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/home/dk/anaconda3/lib/python3.5/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: invalid continuation byte

I tried uninstalling and reinstalling anaconda and it doesn't seem to work I am open to suggestions, I am very much new to python, so I would appriciate a simple explanation of the possible causes of the error too.

Thanks in advance


回答1:


Well here is how I solved the issue.
l opened this: spyderlib/userconfig.py
and changed this: self.read(self.filename(), encoding='utf-8')
to this: self.read(self.filename(), encoding='latin-1')
It gave me a Warning: File contains no section headers but started spyder anyway. After that, I closed spyder, opened the terminal and entered spyder --reset then restarted spyder, it seems to work now.
Here is what you should not do at all costs for this problem: thinkering with these, I learned my lesson the hard way:

python3.5/configparser.py
python3.5/codecs.py


来源:https://stackoverflow.com/questions/36958189/spyder-unicode-decode-error-in-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!