Repository: spyder-ide/spyder

Issue:
UnicodeDecodeError when opening a project

## Problem Description
Use the following command to upgrade to 5.0.1, can not start.
```
conda install spyder=5.0.1
```
### What steps reproduce the problem?
![spyder5 0 1无法启动](https://user-images.githubusercontent.com/1759365/115169933-f43af880-a0f1-11eb-9b8e-e8e164decc9a.gif)


### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback
No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect.
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2172, in create_window
    main.post_visible_setup()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 1300, in post_visible_setup
    self.projects.reopen_last_project()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\plugins\projects\plugin.py", line 544, in reopen_last_project
    self.open_project(path=current_project_path,
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\plugins\projects\plugin.py", line 402, in open_project
    project_type_class = self._load_project_type_class(path)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\plugins\projects\plugin.py", line 812, in _load_project_type_class
    config.read(fpath)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\configparser.py", line 697, in read
    self._read(fp, filename)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\configparser.py", line 1017, in _read
    for lineno, line in enumerate(fp, start=1):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 233: illegal multibyte sequence
```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 5.0.1
* Python version: 3.8.8
* Qt version: 5.9.7
* PyQt version: 5.9.2
* Operating System name/version: win10



Discussion:
Hey @leavor, thanks for reporting. We'll take a look at this in our next version.

For now please run

    spyder --reset

and don't create projects in directories that contain non-latin characters.
After use the "spyder --reset" in Anaconda,Spyder can start, but there is another problem.
First, I opened an existing project named "Algorithm", and failed. The bug report is the same as above.
Then, I created a new folder named "aaa" as a project folder, which also failed.

<details>

```python-traceback
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 113, in get_comm
    return self.comms[comm_id]
KeyError: '7802ea37a0b611eb8dcb1c1b0da66787'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2207, in create_window
    app.exec_()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 48, in _dispatch
    getattr(self, msg_type)(msg)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 172, in comm_msg
    comm = self.get_comm(comm_id)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 117, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('7802ea37a0b611eb8dcb1c1b0da66787',)
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 113, in get_comm
    return self.comms[comm_id]
KeyError: '7802ea37a0b611eb8dcb1c1b0da66787'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2207, in create_window
    app.exec_()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 48, in _dispatch
    getattr(self, msg_type)(msg)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 172, in comm_msg
    comm = self.get_comm(comm_id)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 117, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('7802ea37a0b611eb8dcb1c1b0da66787',)
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 113, in get_comm
    return self.comms[comm_id]
KeyError: '7802ea37a0b611eb8dcb1c1b0da66787'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2207, in create_window
    app.exec_()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 48, in _dispatch
    getattr(self, msg_type)(msg)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 172, in comm_msg
    comm = self.get_comm(comm_id)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 117, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('7802ea37a0b611eb8dcb1c1b0da66787',)
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 113, in get_comm
    return self.comms[comm_id]
KeyError: '7802ea37a0b611eb8dcb1c1b0da66787'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2207, in create_window
    app.exec_()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 48, in _dispatch
    getattr(self, msg_type)(msg)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 172, in comm_msg
    comm = self.get_comm(comm_id)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 117, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('7802ea37a0b611eb8dcb1c1b0da66787',)
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 113, in get_comm
    return self.comms[comm_id]
KeyError: '7802ea37a0b611eb8dcb1c1b0da66787'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2207, in create_window
    app.exec_()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 48, in _dispatch
    getattr(self, msg_type)(msg)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 172, in comm_msg
    comm = self.get_comm(comm_id)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 117, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('7802ea37a0b611eb8dcb1c1b0da66787',)
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 113, in get_comm
    return self.comms[comm_id]
KeyError: '7802ea37a0b611eb8dcb1c1b0da66787'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\start.py", line 214, in main
    mainwindow.main(options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2311, in main
    mainwindow = create_window(app, splash, options, args)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\spyder\app\mainwindow.py", line 2207, in create_window
    app.exec_()
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 48, in _dispatch
    getattr(self, msg_type)(msg)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 172, in comm_msg
    comm = self.get_comm(comm_id)
  File "C:\Users\Admin\Anaconda3\envs\python3.8.8\lib\site-packages\qtconsole\comms.py", line 117, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('7802ea37a0b611eb8dcb1c1b0da66787',)

```

</details>

Finally, I opened the existing new project "aaa" , succeeded

![spyder5 0 1无法使用中文目录](https://user-images.githubusercontent.com/1759365/115172948-d755f380-a0f8-11eb-8289-f8ade81d1b58.gif)

Please close Spyder, open the Anaconda prompt and run there

    conda install jupyter_client=6.1.12

That should solve your problem.
I found the second you reported above (i.e. the one with the very long error traceback) is a duplicate of issue #15356. We'll fix it in our next release.
Hi, @ccordoba12 , I have fixed this bug.
![image](https://user-images.githubusercontent.com/1759365/135215703-8a97858a-7746-4a7a-a124-5f99ff5caf11.png)

I changed the code in this file, "python\Lib\site-packages\spyder\plugins\projects\plugin.py"
However, I am not sure about the impact of this on spyder's entire project.
![image](https://user-images.githubusercontent.com/1759365/135222930-45891ad0-9ead-492c-be46-b5d0c225c3a4.png)

> Hi, @ccordoba12 , I have fixed this bug.

Hey @leavor, that's really good to hear!

Do you want me to submit a pull request for this? Or do you prefer to do it?
@ccordoba12 Yes, you submit a PR. 
Ok, no problem. I'll do it.

Resolving patch:
diff --git a/spyder/plugins/projects/plugin.py b/spyder/plugins/projects/plugin.py
--- a/spyder/plugins/projects/plugin.py
+++ b/spyder/plugins/projects/plugin.py
@@ -861,7 +861,7 @@ def _load_project_type_class(self, path):
         project_type_id = EmptyProject.ID
         if osp.isfile(fpath):
             config = configparser.ConfigParser()
-            config.read(fpath)
+            config.read(fpath, encoding='utf-8')
             project_type_id = config[WORKSPACE].get(
                 "project_type", EmptyProject.ID)
 


Test patch: