此问题在此处已有答案:
What can I do about "ImportError: Cannot import name X" or "AttributeError: ... (most likely due to a circular import)"?(17个答案)
上个月关门了。
这篇文章是27天前编辑并提交审查的。
我有这样的代码:
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()
我收到一个错误消息:
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
我以前在我的PC上使用Matplotlib,我删除并重新安装了Python和IntelliJ。
出什么问题了?我该怎么解决?
1条答案
按热度按时间hyrbngr71#
你可以把这些代码加到