Repository: spyder-ide/spyder
Pull request: PR: Add Matplotlib font cache message to benign errors (IPython console)
<!--- Make sure to read the Contributing Guidelines:                   --->
<!--- https://github.com/spyder-ide/spyder/blob/master/CONTRIBUTING.md --->
<!--- and follow PEP 8, PEP 257 and Spyder's code style:               --->
<!--- https://github.com/spyder-ide/spyder/wiki/Dev:-Coding-Style      --->

## Description of Changes

<!--- Explain what you've done and why --->


Add matplotlib error to benign messages


### Issue(s) Resolved

<!--- List the issue(s) below, in the form "Fixes #1234"; one per line --->

Fixes #24153


### Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the [Developer Certificate of Origin](https://developercertificate.org)
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

<!--- TYPE YOUR USER/NAME AFTER THE FOLLOWING: --->
I certify the above statement is true and correct:
@jsbautista 
<!--- Thanks for your help making Spyder better for everyone! --->


Problem statement:
Error in console with message `Matplotlib is building the font cache; this may take a moment.`
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

Hello, I recently updated Spyder using Anaconda and insde the iPython console I keep getting the following error:
"An error occured while starting the kernel
Matplotlib is building the font cache; this may take a moment."

The console has not been available to me since I updated Spyder several days ago (I have given it many "moments" to build the font cache) and I'm not sure how to resolve.

I launch Spyder using my Terminal.



## Versions

* Spyder version: 6.0.3  (conda)
* Python version: 3.9.18 64-bit
* Qt version: 5.15.2
* PyQt5 version: 5.15.10
* Operating System: Linux-6.5.0-26-generic-x86_64-with-glibc2.35

### Dependencies

```
# Mandatory:
aiohttp >=3.9.3                  :  3.11.10 (OK)
asyncssh >=2.14.0,<3.0.0         :  2.17.0 (OK)
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  4.0.0 (OK)
cloudpickle >=0.5.0              :  3.0.0 (OK)
cookiecutter >=1.6.0             :  2.6.0 (OK)
diff_match_patch >=20181111      :  20230430 (OK)
github >=2.3.0                   :  2.4.0 (OK)
importlib_metadata >=4.6.0       :  8.5.0 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.15.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.2 (OK)
jellyfish >=0.7                  :  1.1.3 (OK)
jsonschema >=3.2.0               :  4.23.0 (OK)
keyring >=17.0.0                 :  24.3.1 (OK)
nbconvert >=4.0                  :  7.16.6 (OK)
numpydoc >=0.6.0                 :  1.7.0 (OK)
parso >=0.7.0,<0.9.0             :  0.8.4 (OK)
pexpect >=4.4.0                  :  4.8.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  5.9.0 (OK)
pygments >=2.0                   :  2.15.1 (OK)
pylint >=3.1,<4                  :  3.3.5 (OK)
pylint_venv >=3.0.2              :  3.0.3 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.12.0,<1.13.0           :  1.12.2 (OK)
pylsp_black >=2.0.0,<3.0.0       :  2.0.0 (OK)
pyuca >=1.2                      :  1.2 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.2 (OK)
qtawesome >=1.3.1,<1.4.0         :  1.3.1 (OK)
qtconsole >=5.6.1,<5.7.0         :  5.6.1 (OK)
qtpy >=2.4.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.1.0 (OK)
setuptools >=49.6.0              :  75.8.0 (OK)
sphinx >=0.6.6                   :  7.3.7 (OK)
spyder_kernels >=3.0.2,<3.1.0    :  3.0.2 (OK)
superqt >=0.6.2,<1.0.0           :  0.6.7 (OK)
textdistance >=4.2.0             :  4.6.2 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  4.0.2 (OK)
xdg >=0.26                       :  0.28 (OK)
yarl >=1.9.4                     :  1.18.0 (OK)
zmq >=24.0.0                     :  26.2.0 (OK)

# Optional:
cython >=0.21                    :  None (NOK)
matplotlib >=3.0.0               :  3.9.2 (OK)
numpy >=1.7                      :  1.26.4 (OK)
pandas >=1.1.1                   :  2.2.3 (OK)
scipy >=0.17.0                   :  1.13.1 (OK)
sympy >=0.7.3                    :  None (NOK)
```

Hints from issue discussion:
Hey @audreyc38, thanks for reporting. You said:

> The console has not been available to me since I updated Spyder several days ago (I have given it many "moments" to build the font cache) and I'm not sure how to resolve.

Does this happen to you for any console you open or only for the first one?

In any case, we'll fix this error in our next version (6.0.6) and instruct you on how to fix it in the meantime.
@jsbautista, to fix this please add the string `Matplotlib is building the font cache` to the list of benign messages in `ipythonconsole/widgets/client.py`, with a comment that references this issue.
> Hey [@audreyc38](https://github.com/audreyc38), thanks for reporting. You said:
> 
> > The console has not been available to me since I updated Spyder several days ago (I have given it many "moments" to build the font cache) and I'm not sure how to resolve.
> 
> Does this happen to you for any console you open or only for the first one?
> 
> In any case, we'll fix this error in our next version (6.0.6) and instruct you on how to fix it in the meantime.

Thanks for the quick response! It occurs for every console.

![Image](https://github.com/user-attachments/assets/dda7b163-f089-49c1-bd5c-cca7545c5c37)

Commit message: add matplotlib error to benign messages

Patch to review:
diff --git a/spyder/plugins/ipythonconsole/widgets/client.py b/spyder/plugins/ipythonconsole/widgets/client.py
index 55b71f92f1f..529b15e0d98 100644
--- a/spyder/plugins/ipythonconsole/widgets/client.py
+++ b/spyder/plugins/ipythonconsole/widgets/client.py
@@ -557,6 +557,8 @@ def is_benign_error(self, error):
             "The system cannot find the path specified",
             # UNC paths, see spyder-ide/spyder#23726
             " UNC ",
+            # Matplotlib error, see spyder-ide/spyder#23726
+            "Matplotlib is building the font cache",
         ]
 
         return any([err in error for err in benign_errors])


Code review comments:
diff_hunk: @@ -557,6 +557,8 @@ def is_benign_error(self, error):
             "The system cannot find the path specified",
             # UNC paths, see spyder-ide/spyder#23726
             " UNC ",
+            # Matplotlib error, see spyder-ide/spyder#23726
path: spyder/plugins/ipythonconsole/widgets/client.py
text: @user1:
```suggestion
            # Matplotlib spurious message, see spyder-ide/spyder#24153
```

Improve comment a bit and reference the right issue.