我想你應該打開matplotlib包並找到pyplot.py。 裏面你應該找到導入pyqt的代碼部分。檢查是否是這樣的:
is_agg_backend = rcParams['backend'].endswith('Agg')
if 'wx' in sys.modules and not backend in ('WX', 'WXAgg'):
import wx
if wx.App.IsMainLoopRunning():
rcParams['backend'] = 'wx' + 'Agg' * is_agg_backend
elif 'PyQt4.QtCore' in sys.modules and not backend == 'Qt4Agg':
import PyQt4.QtGui
if not PyQt4.QtGui.qApp.startingUp():
# The mainloop is running.
rcParams['backend'] = 'qt4Agg'
elif 'PyQt5.QtCore' in sys.modules and not backend == 'Qt5Agg':
import PyQt5.QtWidgets
if not PyQt5.QtWidgets.qApp.startingUp():
# The mainloop is running.
rcParams['backend'] = 'qt5Agg'
elif ('gtk' in sys.modules and
backend not in ('GTK', 'GTKAgg', 'GTKCairo')):
if 'gi' in sys.modules:
from gi.repository import GObject
ml = GObject.MainLoop
else:
import gobject
ml = gobject.MainLoop
if ml().is_running():
rcParams['backend'] = 'gtk' + 'Agg' * is_agg_backend
elif 'Tkinter' in sys.modules and not backend == 'TkAgg':
# import Tkinter
pass # what if anything do we need to do for tkinter?
_backend_selection()
的這部分程序,檢查是否有這些GUI框架中的至少一個。
讓我知道
是的,那就是backend_detection()。抽象相同 –