Prevent Python kernal from crashing when running an application in QT

浪尽此生 提交于 2019-12-11 02:57:23

问题


I am attempting to write a program using PysideQT using Spyder. While the application runs fine from command line, the program causes the Python's Kernel to crash when running from Spyder's interpretive Python kernel. I cannot figure out what is causing the issue. I am running Ubuntu LTS 14.04 on a 64bit system. Once again, this issue does not occur when I run the program from terminal.

I have written the following program that causes the Kernel to crash:

import sys
import PySide.QtGui as qg
app = qg.QApplication(sys.argv)

Here is a dump from the console output:

It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.

Any help would be appreciated.


回答1:


I found an solution. Essentially, you can't use sys.argv from Spyder because the way Spyder launches the program it's undefined. You can manually setup Spyder to specify it or you can just replace sys.argv with the file name, in my case fileloader.py.



来源:https://stackoverflow.com/questions/30789926/prevent-python-kernal-from-crashing-when-running-an-application-in-qt

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