简体   繁体   中英

Import error for matplotlib.pyplot

I saw similar posts, but the error given when I tried to run import matplotlib.pyplot as plt was different:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in <module>
    from .backend_qt5 import QtCore
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 26, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 56, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "/home/jhn545/miniconda2/lib/python2.7/site-packages/matplotlib/backends/qt_compat.py", line 128, in <module>
    from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: libQt5Core.so.5: object file has no loadable segments

I'm using miniconda2 and have already tried un-installing and re-installing matplotlib

Thank you @SiHa. The post at Set Matplotlib Backend worked perfectly.

One of the answers on that post also gave useful info on how to set the default backend. Simply go to your matplotlibrc file (mine was at miniconda2/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc ) and change the backend variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM