Repository: spyder-ide/spyder

Issue:
`KeyError: 'workspace'` when opening a project
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [ x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [ x] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [ x] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ x] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [ x] Tried basic troubleshooting (if a bug/error)
    * [x ] Restarted Spyder
    * [x ] Reset preferences with ``spyder --reset``
    * [x ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [x ] Tried the other applicable steps from the Troubleshooting Guide
* [ x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description

Can't open an old project after updating my spyder


### What steps reproduce the problem?

1. Try to open a project

### What is the expected output? What do you see instead?



### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

Traceback (most recent call last):
  File "C:\kaleb\miniconda\envs\keep\lib\site-packages\spyder\plugins\projects\plugin.py", line 314, in <lambda>
    triggered=lambda v: self.open_project())
  File "C:\kaleb\miniconda\envs\keep\lib\site-packages\spyder\plugins\projects\plugin.py", line 471, in open_project
    project_type_class = self._load_project_type_class(path)
  File "C:\kaleb\miniconda\envs\keep\lib\site-packages\spyder\plugins\projects\plugin.py", line 903, in _load_project_type_class
    project_type_id = config[WORKSPACE].get(
  File "C:\kaleb\miniconda\envs\keep\lib\configparser.py", line 958, in __getitem__
    raise KeyError(key)
KeyError: 'workspace'

```

## 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.2.1 None
* Python version: 3.7.12 64-bit
* Qt version: 5.12.9
* PyQt5 version: 5.12.3
* Operating System: Windows 10

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:
Thanks for reporting. This issue is a duplicate of #13346 and fixed in our latest version. Please update by opening the Anaconda Prompt and running there:<br><br>`conda update anaconda`<br>`conda install spyder=4.1.5`
Hey @kaleb-keny, thanks for reporting. This was closed incorrectly by our bot but we'll try to fix it in our next version.

In the meantime, please remove the `.spyproject` directory located in your project one, and recreate your project again.
sure will do thank you 🙏🏼 

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
@@ -900,8 +900,15 @@ def _load_project_type_class(self, path):
         if osp.isfile(fpath):
             config = configparser.ConfigParser()
             config.read(fpath, encoding='utf-8')
-            project_type_id = config[WORKSPACE].get(
-                "project_type", EmptyProject.ID)
+
+            # This is necessary to catch an error for projects created in
+            # Spyder 4 or older versions.
+            # Fixes spyder-ide/spyder17097
+            try:
+                project_type_id = config[WORKSPACE].get(
+                    "project_type", EmptyProject.ID)
+            except KeyError:
+                pass
 
         EmptyProject._PARENT_PLUGIN = self
         project_types = self.get_project_types()


Test patch: