[英]Prevent Python kernal from crashing when running an application in QT
I am attempting to write a program using PysideQT using Spyder.我正在尝试使用 Spyder 使用 PysideQT 编写程序。 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.
虽然应用程序从命令行运行良好,但当从 Spyder 的解释性 Python 内核运行时,该程序会导致 Python 的内核崩溃。 I cannot figure out what is causing the issue.
我无法弄清楚是什么导致了这个问题。 I am running Ubuntu LTS 14.04 on a 64bit system.
我在 64 位系统上运行 Ubuntu LTS 14.04。 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.任何帮助,将不胜感激。
I found an solution.我找到了解决方案。 Essentially, you can't use sys.argv from Spyder because the way Spyder launches the program it's undefined.
本质上,您不能使用来自 Spyder 的 sys.argv,因为 Spyder 启动程序的方式是未定义的。 You can manually setup Spyder to specify it or you can just replace sys.argv with the file name, in my case fileloader.py.
你可以手动设置 Spyder 来指定它,或者你可以用文件名替换 sys.argv,在我的例子中是 fileloader.py。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.