简体   繁体   English

为什么我的情节会在Spyder之外的matplotlib中冻结/不显示

[英]Why does my plot freeze/not show in matplotlib outside of Spyder

So I have the following code: 所以我有以下代码:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import colors

plt.ion()

example_data = np.random.randint(5, size=(44,80))
cmap = colors.ListedColormap(['black','white','green','blue','red'])
bounds = [0,1,2,3,4,5]
norm = colors.BoundaryNorm(bounds, cmap.N)

img = plt.imshow(example_data, interpolation='nearest',origin='lower',cmap=cmap, norm=norm)
plt.draw()

If I run this with the backend in matplotlibrc set to Qt4Agg, I get the plot appearing but the window is 'Not responding' and needs to be forced to close. 如果我在matplotlibrc中设置为Qt4Agg的后端运行它,我得到的情节出现,但窗口是“没有响应”,需要强制关闭。

If I run it with the backend set to GTK3Agg (Which is what I'm aiming for really) I get a blank plot window with no plot on it and the message 'python.exe has stopped working' 如果我运行它后端设置为GTK3Agg(这是我真正的目标)我得到一个空白的绘图窗口,没有绘图和消息'python.exe已停止工作'

If I run it within Spyder then it all works fine (Backend is Qt4Agg here I think). 如果我在Spyder中运行它然后一切正常(我认为后端是Qt4Agg)。 I get exactly what I want and no freezing/unresponsiveness. 我得到了我想要的东西,没有冷冻/反应迟钝。

Could anyone help? 有人可以帮忙吗? I think I'm not fully understanding the interactive issues with running it outside of the IDE. 我想我并没有完全理解在IDE之外运行它的交互式问题。

Thanks. 谢谢。

EDIT: Error log is: 编辑:错误日志是:

Traceback (most recent call last)
  File"<string>", line 73, in execInThread
  File"<string>", line 44, in __call__
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 196, in __call__
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 71, in syncerq
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 431, in sync_request
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 379, in serve
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 337, in _recv
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py", line 50, in recv
  File"C:\Program Files\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 166, in read
EOFError: [WinError 10054] An existing connection was forcibly closed by the remote host

EDIT2: EDIT2:

So looking in the Windows Event viewer logs I can see I get: 因此,查看Windows事件查看器日志,我可以看到:

ERROR - APPLICATION ERROR: 错误 - 应用程序错误:

Faulting Application name:python.exe, version 0.0.0.0, time stamp: 0x54f9ed12
Faulting module name: libcairo-2.dll, version 0.0.0.0, time stamp 0x50a184bb
Exception code: 0xc0000005
Fault offset: 0x00023024
Faulting process id: 0xca8
Faulting application start time: 0x01d1f7a6ba424ee5
Faulting application path: C:\Anaconda3\python.exe
Faulting module path: C:\Anaconda3\Lib\site-packages\GTK+-Bundle-3.6.1\bin\libcairo-2.dll
Report Id: ff7c449c-6399-11e6-ba70-0cc47a6a54fd

So maybe it's something to do with the libcairo-2.dll? 那么也许这与libcairo-2.dll有关? I reinstalled GTK to see if that helped but appears to have made no difference. 我重新安装GTK,看看是否有所帮助,但似乎没有任何区别。

在PyScripter 2.7.10的菜单Run-> Python engine - > Internal中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM