2

I tried to run, on IDLE, the following example code, which was copied from matplotlib's official website:

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)

But I got lots of errors:

Traceback (most recent call last):
  File "D:/temp/pyplot_test.py", line 2, 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.py", line 14, in <module>
    import matplotlib.axis as maxis
  File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 12, in <module>
    import matplotlib.patches as mpatches
  File "C:\Python27\lib\site-packages\matplotlib\patches.py", line 1615, in <module>
    class BoxStyle(_Style):
  File "C:\Python27\lib\site-packages\matplotlib\patches.py", line 2068, in BoxStyle
    {"AvailableBoxstyles": _pprint_styles(_style_list)}
  File "C:\Python27\lib\site-packages\matplotlib\patches.py", line 1539, in _pprint_styles
    args, varargs, varkw, defaults =  inspect.getargspec(cls.__init__)
AttributeError: 'module' object has no attribute 'getargspec'

My computer is a Windows XP machine. Python and matplotlib (and other site packages such as numpy) were installed cleanly using Python(x,y). Any idea how to resolve this issue?

4
  • 7
    Do you happen to have a custom inspect.py module lying around? When you enter import inspect; inspect, what does it print? Commented Feb 11, 2012 at 10:41
  • Yes. So, there is a name clash. After changing the filename, the code works now. Thanks very much. If you turn the comment into an answer I will flag it as the correct answer. Commented Feb 11, 2012 at 11:19
  • I didn't understand the problem, when I run import inspect; inspect, I get following output <module 'inspect' from 'C:\Python27\lib\inspect.pyc'>, what does it mean and how to I still import matlibplot for plotting purpose. Commented Jul 9, 2012 at 23:03
  • @VaidAbhishek it means that you did not have the same problem that OP did. Commented Jan 14, 2024 at 23:06

1 Answer 1

1

Try importing matplotlib.pylab, as it is alias for pyplot.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.