在iPython上使用matplotlib运行PyQt5时崩溃

在iPython上使用matplotlib运行PyQt5时崩溃,python,matplotlib,ipython,pyqt5,Python,Matplotlib,Ipython,Pyqt5,我想在自己的GUI应用程序上使用matplotlib,所以决定使用PyQt5实现它。我在下面编写了测试代码 import sys from PyQt5.QtWidgets import QApplication, QMainWindow import matplotlib as mpl mpl.use('Qt5Agg') import matplotlib.pyplot as plt class MyApp(QMainWindow): def __init__(self):

我想在自己的GUI应用程序上使用matplotlib,所以决定使用PyQt5实现它。我在下面编写了测试代码

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow

import matplotlib as mpl
mpl.use('Qt5Agg')
import matplotlib.pyplot as plt


class MyApp(QMainWindow):
    def __init__(self):
        super().__init__()
        self.show()
        self.raise_()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = MyApp()
    sys.exit(app.exec_())
然而,我面临着一个奇怪的问题。 当我在iPython上运行代码时,没有问题。 第二次跑步也可以。 但是,在我第三次启动并关闭应用程序后,iPython冻结了一些消息。信息如下

QEventLoop: Cannot be used without QApplication
QSocketNotifier: Can only be used with threads started with Thread
这个问题可以在我的电脑上重现。为什么会发生这样的崩溃? 我使用python(3.5.2)、iPython(5.1.0)和matplotlib(1.5.3)。PC的操作系统是MacOSX(10.11.4)