如何在Ubuntu中导入matplotlib.pyplot

时间:2018-09-16 16:32:46

标签: ubuntu python-3.6 meep

我正在Ubuntu中使用Python3的MEEP。激活MEEEP后,我一次import matplotlib.pyplot as plt。然后显示错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
    [backend_name], 0)
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py", line 15, in <module>
    from .backend_qt5 import (
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 19, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 54, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "/home/tim/anaconda3/envs/meep/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py", line 158, in <module>
    raise ImportError("Failed to import any qt binding")
ImportError: Failed to import any qt binding

如何解决此问题?感谢您的评论并提前提供帮助

1 个答案:

答案 0 :(得分:0)

我发现安装python3-pyqt5解决了该问题:

apt-get install python3-pyqt5