I just committed a major noob blunder while playing around with basic functionalities of NumPy. I created a small file called "numpy.py" just so that play around with problems related to numpy. I could also later come back for reference - and the name would have helped. Obvious error :-
import numpy
File "C:\Users\USERNAME\workspace\StackOverflow\python\numpy.py", line 25, in <module>
AttributeError: 'module' object has no attribute 'random'
I realized the problem - python was considering my current code as actual numpy and looking for random. I deleted that file and created a new one.
And the problem persists. This image explains it better than my words would.
Now there's a completely new file with a different name - but still it's looking for some methods in the deleted file.
I've already tried:
- Cleaning the Project
- Restarting Eclipse
- Run another .py (successfully) and then this one again
- Removed all the conflicting files, created a totally new file. Still same. If the program contains import numpy, it would give same error.
I'd like to know (1) What actually happened wrong here? Why is eclipse so confused (2) How to resolve? (3) What are the best practices in such situations?
I'm the OP. Found a solution after a few minutes of posting this question.
Browsed to the folder containing the code. I noticed that there was a .pyc file for the numpy.pyc I had created earlier. Deleted that one and things are working file now.
However I'd still like to know how to avoid situations like this or resolve directly through eclipse. Though it works now!