0

I am Unable to import matplotlib

I am able to import it through command prompt(python interpreter) But when i use it in a program with just one line import matplotlib as plt I am getting theese errors

Traceback (most recent call last):
  File "D:\python\gis\test.py", line 1, in <module>
    import matplotlib as plt
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 133, in <module>
    from matplotlib.rcsetup import (defaultParams,
  File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 19, in <module>
    from matplotlib.colors import is_color_like
  File "C:\Python27\lib\site-packages\matplotlib\colors.py", line 54, in <module>
    import matplotlib.cbook as cbook
  File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 15, in <module>
    import new
  File "D:\python\gis\new.py", line 27, in <module>
    nx.draw(G, pos=pos)
  File "C:\Python27\lib\site-packages\networkx-1.7.dev_20120522142611-py2.7.egg\networkx\drawing\nx_pylab.py", line 114, in draw
    raise ImportError("Matplotlib required for draw()")
ImportError: Matplotlib required for draw()

I have checked the path it contains only C:/python27 only not other python directories Guys please help me out

Rakesh12
  • 409
  • 2
  • 6
  • 14

1 Answers1

2

The D:\python\gis\new.py module is shadowing the Python standard library new module. Try rename your new module.

cgohlke
  • 9,142
  • 2
  • 33
  • 36
  • This worked I do not know why i did not try before But now I am getting a runtime error for pythonw.exe from microsoftvisualc++ library if i edit it – Rakesh12 May 28 '12 at 21:20