首页 > 解决方案 > UnicodeDecodeError on Spyder startup

问题描述

I have a problem similar to this post. When trying to start Spyder from terminal or Anaconda navigator, I get the error:

    Traceback (most recent call last):
  File "/home/myuser/anaconda3/bin/spyder", line 7, in <module>
    from spyder.app.start import main
  File "/home/myuser/anaconda3/lib/python3.8/site-packages/spyder/app/start.py", line 35, in <module>
    from spyder.config.manager import CONF
  File "/home/myuser/anaconda3/lib/python3.8/site-packages/spyder/config/manager.py", line 351, in <module>
    CONF = ConfigurationManager()
  File "/home/myuser/anaconda3/lib/python3.8/site-packages/spyder/config/manager.py", line 64, in __init__
    self._user_config = MultiUserConfig(
  File "/home/myuser/anaconda3/lib/python3.8/site-packages/spyder/config/user.py", line 782, in __init__
    self._configs_map[name] = config_class(**new_kwargs)
  File "/home/myuser/anaconda3/lib/python3.8/site-packages/spyder/config/user.py", line 212, in __init__
    self._load_from_ini(previous_fpath)
  File "/home/myuser/anaconda3/lib/python3.8/site-packages/spyder/config/user.py", line 333, in _load_from_ini
    self.read(fpath, encoding='utf-8')
  File "/home/myuser/anaconda3/lib/python3.8/configparser.py", line 697, in read
    self._read(fp, filename)
  File "/home/myuser/anaconda3/lib/python3.8/configparser.py", line 1017, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/home/myuser/anaconda3/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 0: invalid start byte

The proposed solution doesn't work for me, as I struggle to find the right file to replace encoding='utf-8' with encoding='latin-1'. The file userconfig.py is not present in my anaconda installation folder. Looking with

grep -rn 'self.read(self.filename(), encoding='

results in the path pkgs/anaconda-navigator-1.9.12-py38_0/lib/python3.8/site-packages/anaconda_navigator/config/user.py:279. But changing that line accordingly doesn't make any difference.

The same problem occurs if I try to run

spyder --reset

My setup: Ubuntu 18.04, Python 3.8.3, Spyder 4.1.4, Qt: 5.9.7, PyQt: 5.9.2

What I tried so far:

I managed to make Spyder start when using an environment with python 2.7 and Spyder versions below 4.0, but i need the newer versions of both python and Spyder for my projects.

I am really stuck here and appreciate any of your advice!

标签: pythonutf-8anacondaspyderubuntu-18.04

解决方案


推荐阅读