尽管后端文件夹中存在文件,但未找到PyQt4。

时间:2017-12-28 10:03:24

标签: python python-3.x qt matplotlib anaconda

我正在尝试运行代码来获取交互式GUI。但是,在尝试使用%matplotlib qt时出现以下错误: 所以,我尝试使用%matplotlib qt5,问题仍然存在。 我检查了后端文件夹。我好像有backend_qt4agg和backend_qt5agg。 我使用的是Conda 4.3.30,Python 3.6.3和Matplotlib 2.1.0版。

任何帮助将不胜感激。谢谢! ModuleNotFoundError:没有名为' PyQt4'



Warning: Cannot change to a different GUI toolkit: qt5. Using qt instead.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-36-29592a41e3d8> in <module>()
      1 #import PyQt4
----> 2 get_ipython().magic('matplotlib qt5')
      3 
      4 matplotlib.use('qt5Agg')
      5 T_P1_G1_Th = plt.figure().gca(projection='3d')

~\Anaconda\lib\site-packages\IPython\core\interactiveshell.py in magic(self, arg_s)
   2144         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2145         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2146         return self.run_line_magic(magic_name, magic_arg_s)
   2147 
   2148     #-------------------------------------------------------------------------

~\Anaconda\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line)
   2065                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2066             with self.builtin_trap:
-> 2067                 result = fn(*args,**kwargs)
   2068             return result
   2069 

<decorator-gen-108> in matplotlib(self, line)

~\Anaconda\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~\Anaconda\lib\site-packages\IPython\core\magics\pylab.py in matplotlib(self, line)
     97             print("Available matplotlib backends: %s" % backends_list)
     98         else:
---> 99             gui, backend = self.shell.enable_matplotlib(args.gui)
    100             self._show_matplotlib_backend(args.gui, backend)
    101 

~\Anaconda\lib\site-packages\IPython\core\interactiveshell.py in enable_matplotlib(self, gui)
   2928                 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
   2929 
-> 2930         pt.activate_matplotlib(backend)
   2931         pt.configure_inline_support(self, backend)
   2932 

~\Anaconda\lib\site-packages\IPython\core\pylabtools.py in activate_matplotlib(backend)
    305 
    306     import matplotlib.pyplot
--> 307     matplotlib.pyplot.switch_backend(backend)
    308 
    309     # This must be imported last in the matplotlib series, after

~\Anaconda\lib\site-packages\matplotlib\pyplot.py in switch_backend(newbackend)
    229     matplotlib.use(newbackend, warn=False, force=True)
    230     from matplotlib.backends import pylab_setup
--> 231     _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    232 
    233 

~\Anaconda\lib\site-packages\matplotlib\backends\__init__.py in pylab_setup(name)
     58     # imports. 0 means only perform absolute imports.
     59     backend_mod = __import__(backend_name, globals(), locals(),
---> 60                              [backend_name], 0)
     61 
     62     # Things we pull in from all backends

~\Anaconda\lib\site-packages\matplotlib\backends\backend_qt4agg.py in <module>()
      8 
      9 from .backend_agg import FigureCanvasAgg
---> 10 from .backend_qt4 import (
     11     QtCore, _BackendQT4, FigureCanvasQT, FigureManagerQT, NavigationToolbar2QT)
     12 from .backend_qt5agg import FigureCanvasQTAggBase

~\Anaconda\lib\site-packages\matplotlib\backends\backend_qt4.py in <module>()
     16 from matplotlib.widgets import SubplotTool
     17 
---> 18 from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__
     19 
     20 from .backend_qt5 import (

~\Anaconda\lib\site-packages\matplotlib\backends\qt_compat.py in <module>()
    148     # have been changed in the above if block
    149     if QT_API in [QT_API_PYQT, QT_API_PYQTv2]:  # PyQt4 API
--> 150         from PyQt4 import QtCore, QtGui
    151 
    152         try:

ModuleNotFoundError: No module named 'PyQt4'
&#13;
&#13;
&#13;

显然,PyQt4已经在anaconda 3中逐步淘汰。如果是这样,我需要调用什么才能让交互式matplot lib使用与此类似的代码:

    import pandas as pd
    from pandas import DataFrame
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    T_P1_G1_Th = plt.figure().gca(projection='3d')
    T_P1_G1_Th.scatter(df['Drehzahl'], df['Moment'], df['T_P1_G1_Th'])
    T_P1_G1_Th.set_xlabel('Engine Speed')
    T_P1_G1_Th.set_ylabel('Torque')
    T_P1_G1_Th.set_zlabel('P1_Temp_thrust side')
    plt.show()

谢谢!

0 个答案:

没有答案