相关疑难解决方法(0)

"UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm

I am trying to plot a simple graph using pyplot, e.g.:

import matplotlib.pyplot as plt
plt.plot([1,2,3],[5,7,4])
plt.show()
Run Code Online (Sandbox Code Playgroud)

but the figure does not appear and I get the following message:

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
Run Code Online (Sandbox Code Playgroud)

I saw in several places that one had to change the configuration of matplotlib using the following:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)

I did this, but then got an error message because it …

python matplotlib pycharm

34
推荐指数
10
解决办法
2万
查看次数

为什么 tkinter(或海龟)似乎丢失或损坏?它不应该是标准库的一部分吗?

当尝试使用 Tkinter 标准库包或其相关功能(海龟图形使用turtle和内置 IDLE IDE)或使用将此作为依赖项的第三方库(例如显示使用 Matplotlib 的图形窗口)。

似乎即使不存在因隐藏标准库模块名称而引起的问题(对于尝试遵循教程并使用海龟图形的初学者来说,这是一个常见问题 -示例 1示例 2示例 3示例 4),通常会发生标准库 Tkinter 无法工作的情况。这是一个大问题,因为许多初学者再次尝试遵循使用海龟图形的教程,并盲目地假设turtle标准库将会存在。

可能会报错:

当 Tkinter 被记录为标准库的一部分时,为什么会出现这样的问题?如何添加或修复缺少的标准库功能?对于特定的 …

python installation tkinter modulenotfounderror

19
推荐指数
1
解决办法
9813
查看次数

导入matplotlib在Heroku上失败

[(几个月前基本上与此相同:导入matplotlib在heroku上没有名为_tkinter的模块失败 .但是,提供的唯一解决方案似乎不起作用.(不幸的是,我不能评论那里给出的答案,因为我没有足够的StackOverflow信誉.))]

我一直在我的应用程序中使用matplotlib进行策划.一切都在当地很好.但是,当我将我的应用程序推送到Heroku时,我得到错误:

import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
Run Code Online (Sandbox Code Playgroud)

我试图绕过Tkinter:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt, mpld3
Run Code Online (Sandbox Code Playgroud)

但是,这仍然会引发同样的错误.

有没有人为此找到了解决方案或者有matplotlib的Heroku应用程序正在运行?我正在运行Python 2.7.13(这也是Heroku在推送应用程序时安装的版本).

python tkinter matplotlib heroku

9
推荐指数
1
解决办法
1715
查看次数