I have this code:
import matplotlib.pyplot as p1lt
#define data
x = [1, 2, 3, 4, 5, 6]
y = [3, 7, 14, 19, 15, 11]
#create line plot
p1lt.plot(x, y)
#show line plot
p1lt.show()
I get an error that says:
Matplotlib support failed
Traceback (most recent call last):
File "C:\Users\G\AppData\Roaming\JetBrains\IdeaIC2022.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 25, in do_import
succeeded = activate_func()
File "C:\Users\G\AppData\Roaming\JetBrains\IdeaIC2022.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_code_executor.py", line 29, in <lambda>
"matplotlib": lambda: activate_matplotlib(self.enableGui),
File "C:\Users\G\AppData\Roaming\JetBrains\IdeaIC2022.2\plugins\python-ce\helpers\pydev\pydev_ipython\matplotlibtools.py", line 110, in activate_matplotlib
gui, backend = find_gui_and_backend()
File "C:\Users\G\AppData\Roaming\JetBrains\IdeaIC2022.2\plugins\python-ce\helpers\pydev\pydev_ipython\matplotlibtools.py", line 47, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
File "D:\books\programming\python17\lib\site-packages\matplotlib\__init__.py", line 677, in __getitem__
plt.switch_backend(rcsetup._auto_backend_sentinel)
File "D:\books\programming\python17\lib\site-packages\matplotlib\pyplot.py", line 251, in switch_backend
switch_backend(candidate)
File "D:\books\programming\python17\lib\site-packages\matplotlib\pyplot.py", line 266, in switch_backend
canvas_class = backend_mod.FigureCanvas
AttributeError: partially initialized module 'matplotlib.backends.backend_macosx' has no attribute 'FigureCanvas' (most likely due to a circular import)
Process finished with exit code 0
I used previously Matplotlib on my PC, I removed and reinstalled Python and IntelliJ.
What is wrong? How do I fix it?
You can just add those code at the head
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With