我得到了这个错误“设置您的Matplotlib后端时出现以下错误!!”打开Spyder时

vh0rcniy  于 2023-08-06  发布在  其他
关注(0)|答案(3)|浏览(225)

所以我只是重新安装了Anaconda,设置了我的env打开Spyder,得到了这个错误:

=========================================================================
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)

字符串

kx5bkwkv

kx5bkwkv1#

这只是发生在我身上,原来我已经在工具>首选项>终端ipython>图形>图形输出> Gtk3中进行了修改
把它改成自动的或其他的,对我很有效

kjthegm6

kjthegm62#

是的,我也面临着同样的问题。
尝试重新安装软件包:
对于Pip用户

pip uninstall matplotlib

字符串
对于Pip3用户

pip3 uninstall matplotlib


重新安装:

pip install matplotlib
pip3 install matplotlib

的字符串

olmpazwi

olmpazwi3#

使用较新版本的个人可能会出现此问题。我在打开Spyder版本5.4.1时遇到此错误,通过删除以下文件夹解决了此错误:
C:\Users....matplotlib.

相关问题