在QT中运行应用程序时,防止Python内核崩溃 [英] Prevent Python kernal from crashing when running an application in QT

查看:408
本文介绍了在QT中运行应用程序时,防止Python内核崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Spyder使用PysideQT编写程序。当应用程序从命令行运行良好时,该程序会导致Python的内核在从Spyder的解释性Python内核运行时崩溃。我无法弄清楚造成这个问题的原因。我在64位系统上运行Ubuntu LTS 14.04。再一次,当我从终端运行程序时,不会发生此问题。

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.

推荐答案

我找到了解决方案。从本质上讲,你不能使用Spyder的sys.argv,因为Spyder启动程序的方式是未定义的。你可以手动设置Spyder来指定它,或者你可以用文件名替换sys.argv,在我的例子中是fileloader.py。

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.

这篇关于在QT中运行应用程序时,防止Python内核崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆