简体   繁体   中英

Anaconda: Attribute error while running pylab with anaconda distribution on Windows

I am trying to import pylab and this is the code that I am writing.

import pylab

pylab.figure(1)
pylab.plot([1,2,3,4],[1,7,3,5])
pylab.show()

But I am getting the error that

File "E:\mitedx1\mitedx2\week1\pylab.py", line 2, in <module>
  import pylab
File "E:\mitedx1\mitedx2\week1\pylab.py", line 4, in <module>
pylab.figure(1)
AttributeError: 'module' object has no attribute 'figure'
[Finished in 0.1s with exit code 1]

I tried to take help from the answers provided here

Anaconda: Unable to import pylab

but to no rescue. I have also checked the path with cmd, and it is showing the inclusion of C:\\Anaconda and C:\\Anaconda\\Scripts there. What would be the solution to fix this problem?

You called your script pylab.py , rename it to something else.

E:\mitedx1\mitedx2\week1\pylab.py # <- you are importing from this not the pylab module

Make sure to delete the E:\\mitedx1\\mitedx2\\week1\\pylab.pyc file also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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