简体   繁体   中英

AttributeError: 'module' object has no attribute 'array'

I am trying to input a matix using numpy and I get the following error:

Traceback (most recent call last):
  File "phase1.py", line 1, in <module>
    import numpy as np 
  File "/home/rockstar/phase1.py", line 2, in <module>
    a= np.array([1,2,3])
AttributeError: 'module' object has no attribute 'array'

I am not sure why this error is there. Could anyone help?

You probably have a file called numpy.py in the same folder that shadows the real numpy module. Rename your .py file and delete its .pyc file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM