在Anacond中运行matplotlib时出错

2024-04-27 02:57:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Python环境中运行以下代码:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()

我在mac上运行终端中的代码,得到以下错误:

^{pr2}$

由于某些原因,当我不在Python中时,我不会得到错误,但是我想使用这个环境,因为我的程序的其他部分需要其他几个具有依赖关系的包。如何修复此错误?在


Tags: 代码import终端plotmatplotlibmacasshow
1条回答
网友
1楼 · 发布于 2024-04-27 02:57:41

快速的答案是:conda install python.app并使用pythonw命令而不是python

在macOS中,存在两种不同类型的Python构建:常规构建和框架构建。为了通过本机GUI框架与macOS正确交互,您需要一个Python框架构建。(https://matplotlib.org/faq/osx_framework.html

相关问题 更多 >