Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

python - Pycharm error while importing matplotlib.pyplot as plt

I am using pycharm for python in windows 8. I have installed the package matplotlib. I am using python 2.7 when i do import matplotlib there is no error.
However if i do matplotlib.pyplot as plt i am getting this following errors:

        Traceback (most recent call last):
  File "C:/Users/PiyushSudip/PycharmProjects/myFirst/test1.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:Python27libsite-packagesmatplotlibpyplot.py", line 23, in <module>
    from matplotlib.figure import Figure, figaspect
  File "C:Python27libsite-packagesmatplotlibfigure.py", line 18, in <module>
    from axes import Axes, SubplotBase, subplot_class_factory
  File "C:Python27libsite-packagesmatplotlibaxes\__init__.py", line 4, in <module>
    from ._subplots import *
  File "C:Python27libsite-packagesmatplotlibaxes\_subplots.py", line 10, in <module>
    from matplotlib.axes._axes import Axes
  File "C:Python27libsite-packagesmatplotlibaxes\_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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

There is a package called six which matplotlib depends on. Check to make sure it's installed, or install it from here: 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.

Also check the other dependencies to make sure you have them all, otherwise you might get another error for a different module


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...