[Python data analysis] module 'numpy' has no attribute 'array'

After installing the Numpy module, I started to do a few small tests and it all worked, but when I created the numpy.py file

numpy.py

import numpy
y = numpy.array([[11,4,2],[2,6,1],[32,6,42]])
print (y)

Error after running:

Traceback (most recent call last):
   File "D:\Python_Reptile\numpy.py", line 1, in <module>
     import numpy
   File "D:\Python_Reptile\numpy.py", line 2, in <module>
     y = numpy.array([[11,4,2],[2,6,1],[32,6,42]])
AttributeError: module 'numpy' has no attribute 'array'


Open Baidu query for a long time, and put the code that passed the previous test into this file to run, all errors are reported, which is really strange! Finally found out that it is the problem of the file name numpy.py

After modifying the file name, the problem is solved, perhaps the reason for the conflict between the file name and the module name!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970638&siteId=291194637