Home > Enterprise >  Matplotlib doesn't plot in macos
Matplotlib doesn't plot in macos

Time:09-18

I have the following straightforward code:

import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [34, 56, 78, 21]
plt.plot(x, y)
plt.show()

But after changing my MacBook Pro to the M1 chip, I'm getting the following error:

Traceback (most recent call last):
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/main.py", line 291, in <module>
    plt.plot(x, y)
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2728, in plot
    return gca().plot(
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2225, in gca
    return gcf().gca()
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 830, in gcf
    return figure()
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/_api/deprecation.py", line 454, in wrapper
    return func(*args, **kwargs)
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 771, in figure
    manager = new_figure_manager(
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 346, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 336, in _warn_if_gui_out_of_main_thread
    if (_get_required_interactive_framework(_get_backend_mod()) and
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 206, in _get_backend_mod
    switch_backend(dict.__getitem__(rcParams, "backend"))
  File "/Users/freddy/PycharmProjects/TPMetodosNoParametricos/venv/lib/python3.8/site-packages/matplotlib/pyplot.py", line 266, in switch_backend
    canvas_class = backend_mod.FigureCanvas
AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'

do you have any idea about it?

My matplotlib version is 3.6.0

CodePudding user response:

i had the same problem today on a different machine in the same matplotlib version. I downgrade to Version 3.5.0 and now it works.

  • Related