1

i had succesfully installed numpy (numpy-1.6.2-win32-superpack-python2.7.exe). But, whenever i try to call any functions i am getting following the error below. Thanks in advance for help.

import numpy as np
if __name__ == "__main__":
    k = np.arange(10)

AttributeError: 'module' object has no attribute 'arange'
3
  • If you fire up the python interpreter and type dir(np) what do you get? Commented Aug 22, 2012 at 18:01
  • 3
    .. you didn't happen to call any programs numpy.py, did you? Commented Aug 23, 2012 at 20:31
  • You could try printing np.__file__ to make sure it's actually the system module and not an accidental script. Commented Aug 23, 2012 at 20:51

3 Answers 3

3

Echoing one of the comments above (as I just had this problem, over 4 years later):

You probably named your file numpy.py. When trying to load a module, I believe the path checks the current directory first, and thus it isn't found.

For sanity, to check that it really is this issue, you should run the Python REPL (python) and type:

import numpy as np, followed by dir(np)

And you should see all of the actual functions as output.

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

Comments

1

This might also happen because you probably named your program file numpy.py (i made the same mistake)

Comments

0

try the following:

for x in dir(np):
    print x

this should list all methods etc of your import, that way you can see if arange() is available.

you could also try

from numpy import *

and then just try:

print arange(10)

Can't think of much else. Odd that the import does not produce an error if arange is not there.

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.