简体   繁体   English

将matplotlib.pyplot导入为plt时出现pycharm错误

[英]Pycharm error while importing matplotlib.pyplot as plt

I am using pycharm for python in windows 8. I have installed the package matplotlib. 我在Windows 8中将pycharm用于python。我已经安装了matplotlib软件包。 I am using python 2.7 when i do import matplotlib there is no error. 我在导入matplotlib时使用的是python 2.7,没有错误。
However if i do matplotlib.pyplot as plt i am getting this following errors: 但是,如果我将matplotlib.pyplot做为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

can anyone help figure out what i am doing wrong? 谁能帮我弄清楚我在做什么错?

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

There is a package called six which matplotlib depends on. 有一个名为6的软件包,matplotlib依赖该软件包。 Check to make sure it's installed, or install it from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#six 检查以确保已安装,或从此处安装: http : //www.lfd.uci.edu/~gohlke/pythonlibs/#six

This site has packaged versions of many python modules which are easy to setup on windows, just download and run. 该站点具有许多python模块的打包版本,可在Windows上轻松设置它们,只需下载并运行即可。

Also check the other dependencies to make sure you have them all, otherwise you might get another error for a different module 还要检查其他依赖项,以确保拥有所有依赖项,否则,对于其他模块,可能会出现另一个错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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