pyplot import引发了ImportError

时间:2016-04-11 19:07:04

标签: python matplotlib

我有一个奇怪的问题,试着导入matplotlib。每当我进行导入

将matplotlib.pyplot导入为plt

我收到以下错误消息(当导入matplotlib时没有错误:

Vendor:  Continuum Analytics, Inc.
Package: mkl
Message: trial mode expires in 30 days
Traceback (most recent call last):
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\qt_compat.py", line 159, in <module>
    from PySide import QtCore, QtGui, __version__, __version_info__
ImportError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Pierre/Dropbox/piR/Coding/Python/Eigene Projekte/GPX_reader/main.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 114, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 18, in <module>
    from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 15, in <module>
    from .backend_qt5 import QtCore
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 31, in <module>
    from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
  File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\qt_compat.py", line 162, in <module>
    "Matplotlib qt-based backends require an external PyQt4, PyQt5,\n"
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.

我在Windows 10上的Anaconda发行版中使用Python 3.5。任何人遇到同样的问题?我的设置中最近唯一的变化是(强制)升级到Windows 10 ......

谢谢,并祝福

皮尔

1 个答案:

答案 0 :(得分:7)

您没有安装PySidePyQt,错误消息很清楚,因为matplotlib依赖于其中任何一个

安装PySide run

pip install -U PySide

从命令行-U代表升级,意味着将已安装的所有软件包升级到最新版本

来自pip的手册页

-U, --upgrade
              Upgrade all packages to  the  newest  available  version.   This
              process  is  recursive  regardless  of  whether  a dependency is
              already satisfied.

但你应该做得很好

pip install PySide

如果由于某种原因您不想升级由pip安装的其他软件包

相关问题