I am just trying to convert a list to a 1D array like so:
import numpy as np print np.array([2, 3, 4])
But I get the following error:
Traceback (most recent call last): File "numpy.py", line 11, in <module> test_run() File "numpy.py", line 8, in test_run print np.array([2, 3, 4]) AttributeError: 'module' object has no attribute 'array'
I tried reinstalling numpy because that seems to have worked for others, but this does not fix the problem.
The Python "AttributeError module 'numpy' has no attribute 'array'" occurs when we have a local file named numpy.py and try to import from the numpy module. To solve the error, make sure to rename any local files named numpy.py . Here is an example of how the error occurs in a file called numpy.py .
You are most likely having a file called numpy.py in your working directory which shadows the real numpy module. Rename that file and remove its numpy.pyc file.
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