Reputation: 37
So I just reinstalled Anaconda, set up my env opened Spyder and got this Error:
=========================================================================
NOTE: The following error appeared when setting your Matplotlib backend!!
=========================================================================
Traceback (most recent call last):
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\spyder_kernels\console\kernel.py", line 477, in _set_mpl_backend
get_ipython().run_line_magic(magic, backend)
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\IPython\core\interactiveshell.py", line 2314, in run_line_magic
result = fn(*args, **kwargs)
File "<C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\decorator.py:decorator-gen-109>", line 2, in matplotlib
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\IPython\core\magic.py", line 187, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\IPython\core\magics\pylab.py", line 99, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\IPython\core\interactiveshell.py", line 3414, in enable_matplotlib
pt.activate_matplotlib(backend)
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\IPython\core\pylabtools.py", line 313, in activate_matplotlib
import matplotlib.pyplot
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\matplotlib\pyplot.py", line 2355, in <module>
switch_backend(rcParams["backend"])
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\matplotlib\pyplot.py", line 221, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\ipykernel\pylab\backend_inline.py", line 9, in <module>
from matplotlib.backends.backend_agg import new_figure_manager, FigureCanvasAgg # analysis: ignore
File "C:\Users\Julian\Anaconda3\envs\PythonGPU\lib\site-packages\matplotlib\backends\backend_agg.py", line 45, in <module>
from PIL import Image
File "C:\Users\Julian\AppData\Roaming\Python\Python37\site-packages\PIL\Image.py", line 64, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\Julian\AppData\Roaming\Python\Python37\site-packages\PIL\__init__.py)
Upvotes: 0
Views: 2242
Reputation: 27
This issue might occur for individuals working with a newer version. I encountered this error when opening Spyder version 5.4.1, and it was resolved by deleting the following folder:
C:\Users\...\.matplotlib.
Upvotes: 0
Reputation: 11
This just happend to me, it turns out that I had modified in Tools>Preferences>Terminal ipython>Graphics>Graphics output> Gtk3
change it to automatic or another, it worked for me
Upvotes: 1
Reputation: 36
Yes, I was also facing the same issue.
Try to re-install the package:
For Pip user:
pip uninstall matplotlib
For Pip3 user:
pip3 uninstall matplotlib
Install again:
pip install matplotlib
pip3 install matplotlib
Upvotes: 0