导入matplotlib.pyplot的错误

时间:2017-07-07 11:08:40

标签: python matplotlib

我看过类似的帖子,但是当我尝试运行import matplotlib.pyplot as plt时给出的错误是不同的:

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

我正在使用miniconda2并且已尝试取消安装并重新安装matplotlib

1 个答案:

答案 0 :(得分:0)

谢谢@SiHa。 Set Matplotlib Backend的帖子完美无缺。

该帖子的答案之一也提供了有关如何设置默认后端的有用信息。只需转到matplotlibrc文件(我的miniconda2/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc}并更改backend变量即可。