PySide QApplication([])段错误,但仅限于非交互式ipython会话

时间:2016-11-10 11:27:11

标签: python qt segmentation-fault pyside

我读到一个空列表作为QApplication的参数应该可以工作(而不是sys.argv)。但是在我的情况下,它在交互式ipython shell中运行时确实有效,但是使用ipython执行它会导致分段错误。 知道为什么会这样吗?有什么区别?

这有效:

[jhennrich@tp-arch qt_test]$ ipython2
Python 2.7.12 (default, Jun 28 2016, 08:31:05) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from PySide.QtCore import *
   ...: from PySide.QtGui import *
   ...: 
   ...: app = QApplication([])
   ...: 
/home/jhennrich/.gtkrc-2.0:38: error: scanner: unterminated string constant

In [2]: 

(我还尝试了更多代码,应用程序显示了一个窗口和东西)

作为脚本执行时,它不起作用:

segfault1.py:

from PySide.QtCore import *
from PySide.QtGui import *

app = QApplication([])

运行它:

[jhennrich@tp-arch qt_test]$ ipython2 segfault1.py 
Segmentation fault (core dumped)
[jhennrich@tp-arch qt_test]$ ipython2

0 个答案:

没有答案