How to import matplotlib.pyplot in Ubuntu

1.1k views Asked by At

I am using MEEP by Python3 in Ubuntu. After activate MEEEP, once I import matplotlib.pyplot as plt. Then it shows error:

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

How to fix this issue? Thanks for your comments and helps in advance

1

There are 1 answers

0
Rtype On

I found installing python3-pyqt5 fixed the issue:

apt-get install python3-pyqt5