【问题标题】:Pycharm error while importing matplotlib.pyplot as plt将 matplotlib.pyplot 作为 plt 导入时出现 Pycharm 错误
【发布时间】:2014-12-05 00:52:00
【问题描述】:

我在 windows 8 中使用 pycharm for python。我已经安装了包 matplotlib。 我正在使用 python 2.7 当我 import matplotlib 没有错误。
但是,如果我执行 ma​​tplotlib.pyplot as plt 我会收到以下错误:

        Traceback (most recent call last):
  File "C:/Users/PiyushSudip/PycharmProjects/myFirst/test1.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 23, in <module>
    from matplotlib.figure import Figure, figaspect
  File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 18, in <module>
    from axes import Axes, SubplotBase, subplot_class_factory
  File "C:\Python27\lib\site-packages\matplotlib\axes\__init__.py", line 4, in <module>
    from ._subplots import *
  File "C:\Python27\lib\site-packages\matplotlib\axes\_subplots.py", line 10, in <module>
    from matplotlib.axes._axes import Axes
  File "C:\Python27\lib\site-packages\matplotlib\axes\_axes.py", line 18, in <module>
    from matplotlib.cbook import _string_to_bool, mplDeprecation
ImportError: cannot import name _string_to_bool

谁能帮忙弄清楚我做错了什么?

【问题讨论】:

  • 试试:pip install six
  • 我已经安装了六个,这个错误现在消失了。但是,仍有一些待处理的错误。

标签: python python-2.7 matplotlib


【解决方案1】:

http://matplotlib.org/users/installing.html#required-dependencies

matplotlib 依赖于一个名为 Six 的包。检查以确保已安装,或从此处安装:http://www.lfd.uci.edu/~gohlke/pythonlibs/#six

本站有很多python模块的打包版本,很容易在windows上安装,下载运行即可。

还要检查其他依赖项以确保您拥有所有依赖项,否则您可能会收到其他模块的另一个错误

【讨论】:

  • 这可能是因为您的版本没有正确安装或更新。尝试通过 lfd.uci.edu/~gohlke/pythonlibs/#matplotlib 安装最新版本。确保您获得了专为您的 python 版本设计的版本,即 32/64 位和 2.7
猜你喜欢
  • 2014-08-09
  • 1970-01-01
  • 2019-02-26
  • 1970-01-01
  • 2017-11-05
  • 2017-12-17
  • 2015-06-08
  • 2016-12-20
  • 1970-01-01
相关资源
最近更新 更多