Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using numpy 'module' object has no attribute 'array' [duplicate]

Tags:

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.

like image 647
The Nightman Avatar asked Apr 10 '16 14:04

The Nightman


People also ask

How do I fix Numpy attribute error?

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 .


1 Answers

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.

like image 189
timgeb Avatar answered Sep 19 '22 03:09

timgeb