python example app hangs on close

为君一笑 提交于 2019-12-08 03:23:49

问题


I am relatively new to python and completely new to vtk, so I started with the Camera.py example program from the vtk.org website. Running Enthought Canopy 1.4.1.1975 on Mac OSX 10.9.4 the example program runs but hangs the python interpreter on close with the following error.

The kernel (user Python environment) has terminated with error code -11. This may be due to a bug in your code or in the kernel itself.

I simplified the example program down to the following and still observe the same behavior.

import vtk 

#Create a renderer, render window, and interactor
renderer = vtk.vtkRenderer();
renderWindow = vtk.vtkRenderWindow();
renderWindow.AddRenderer(renderer);
renderWindowInteractor = vtk.vtkRenderWindowInteractor();
renderWindowInteractor.SetRenderWindow(renderWindow);

#Render and interact
renderWindow.Render();
renderWindowInteractor.Start();

I found a similar (unresolved) question here, but his test code (pasted below) crashes immediately for me, whereas my test app runs but crashes on close.

import vtk
test = vtk.vtkRenderer()
test.Render()

Luckily (kind-of), when I embed the Camera example above in a simple wxPython GUI, the crashing behavior becomes less predictable and I have been able to proceed slowly (with many kernel restarts) in developing my actual application. Embedded in the GUI, it frequently hangs on close, occasionally crashes while running, and sometimes even runs correctly.

Thank you for your help!

Update: After disabling pylab and restarting Canopy, my simplified test program above runs and closes cleanly (so far) but the 3-line render example above still crashes immediately. My actual application with vtk in a wxPython window now repeatably fails to close in a new way when I click the red "close" circle on the window. The vtk panel disappears but the rest of the window stays on the screen.


回答1:


Try disabling pylab in the Python pane of the Canopy Preferences dialog.



来源:https://stackoverflow.com/questions/24919601/python-example-app-hangs-on-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!