The following code executed from an IDLE window produces an error shown below.
import numpy as np
testarray = np.array([1,2,3], int)
Here is the error...
Traceback (most recent call last):
File "C:\Test\numpy.py", line 1, in <module>
import numpy as np
File "C:\Test\numpy.py", line 2, in <module>
testarray = np.array([1,2,3], int)
AttributeError: 'module' object has no attribute 'array'
>>>
If I do the same thing in the Shell, it works just fine...
>>> import numpy as np
>>> testarray = np.array([1,2,3], int)
>>> testarray
array([1, 2, 3])
>>>
This has been holding me up all day... anyone know how fix it? Perhaps I'm doing something wrong.
Note: If I just execute the code above without the testarray, no error gets returned.
You named a file numpy.py
. Python sees that in the module search path and thinks it's the implementation of numpy
. Pick a different name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With