简体   繁体   English

在 QT 中运行应用程序时防止 Python 内核崩溃

[英]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.

相关问题 Python 在运行 PyQt5 应用程序时崩溃 - Python crashing when running a PyQt5 application Python Pyside QT-在CLI上运行时防止由于导入导致的QT初始化 - Python Pyside QT - Prevent Initialization of QT due to imports when running on CLI 在 Python 上使用 Pickle 的应用程序在运行时崩溃 - App Using Pickle On Python Crashing When Running Python-运行hdf5文件时崩溃 - Python - Crashing when running hdf5 files 运行新脚本时如何防止python IDLE重新启动 - How to prevent python IDLE from restarting when running new script 防止 Linux 在 Python 进程运行时休眠 - Prevent Linux from sleeping when Python process running 当我制作 python 3 jupyter 笔记本时,这个内核错误是什么? - What is this kernal error when I make a python 3 jupyter notebook? 如何防止我的Selenium / Python程序崩溃? - How to prevent my Selenium/Python program from crashing? 使用 QT 运行 pytest 时发生致命 Python 错误 - Fatal Python Error when running pytest with QT 从命令行运行 python:应用程序无法启动,因为它无法找到或加载 Qt 平台插件“windows” - running python from command line: application failed to start because it could not find or load the Qt platform plugin “windows”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM