29

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.

0

1 Answer 1

116

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.

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

4 Comments

Yep, that was my problem!
It was a file called platform.py in my case!
Whlist following a tutorial I had called my test class numpy.py and this was being loaded instead...!
nice conflict same a filename are crazy system, rename work a thanks timgeb

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.