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
418 views
in Technique[技术] by (71.8m points)

python - AttributeError: 'module' object has no attribute 'cbook'

I am trying to run a simple code and I have all the dependencies for matplotlib and numpy installed in my Canopy. Still I am getting error.

    import cv2
    import numpy as np
    import matplotlib.pyplot as plt
    x = cv2.imread('jay.jpg')
    plt.imshow(x, cmap = 'gray', interpolation = 'bicubic')
    plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
    plt.show()

Error:

     %run "c:usersjayappdatalocalempmppvibq9.py"
     ---------------------------------------------------------------------------
     AttributeError                            Traceback (most recent call last)
     c:usersjayappdatalocalempmppvibq9.py in <module>()
     2 import numpy as np
     3 import matplotlib.cbook
     ----> 4 import matplotlib.pyplot as plt
     5 
     6 x = cv2.imread('jay.jpg')

     C:UsersJayAppDataLocalEnthoughtCanopySystemLibsite-packagesmatplotlibpyplot.py in <module>()
     27 from cycler import cycler
     28 import matplotlib
     ---> 29 import matplotlib.colorbar
     30 from matplotlib import style
     31 from matplotlib import _pylab_helpers, interactive

     C:UsersJayAppDataLocalEnthoughtCanopySystemLibsite-packagesmatplotlibcolorbar.py in <module>()
     30 
     31 import matplotlib as mpl
     ---> 32 import matplotlib.artist as martist
     33 import matplotlib.cbook as cbook
     34 import matplotlib.collections as collections

     C:UsersJayAppDataLocalEnthoughtCanopySystemLibsite-packagesmatplotlibartist.py in <module>()
     9 import numpy as np
     10 import matplotlib
     ---> 11 import matplotlib.cbook as cbook
     12 from matplotlib.cbook import mplDeprecation
     13 from matplotlib import docstring, rcParams

     AttributeError: 'module' object has no attribute 'cbook'

Dependencies I have installed for numpy and matplotlib: 1.) libsvm-3.17.win64-py2.7 2.) pyparsing-2.0.3-1.win64-py2.7 3.) python-dateutil-2.4.2-2.win64-py2.7 4.) pytz-2015.7-1.win64-py2.7 5.) six-1.10.0-1.win64-py2.7 6.) scipy-0.13.3.win64-py2.7 7.) numpy-MKL-1.9.2-2.win64-py2.7 8.) Matplotlib 1.5.1-win64-py2.7 9.) pip 8.0.2-1.win64-py2.7

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Try this:

  1. Close your jupyter notebook and terminate ipython.
  2. Restart Terminal
  3. Enter this command in Terminal:

export LANG=en_US.UTF-8;export LC_ALL=en_US.UTF-8

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

...