Python 数据分析module ‘numpy‘ has no attribute ‘array‘

Posted 奔跑的金鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python 数据分析module ‘numpy‘ has no attribute ‘array‘相关的知识,希望对你有一定的参考价值。

安装好Numpy模块后,开始做了几个小测试都可以运行,但是当我创建numpy.py这个文件后

numpy.py

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

运行后报错了:

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‘


打开百度查询了许久,并且将之前测试通过的代码放到该文件运行,都报错,真是奇了怪了!最后终于发现是文件名称numpy.py的问题

修改文件名称后问题解决,或许是文件名与模块名冲突的原因吧!







以上是关于Python 数据分析module ‘numpy‘ has no attribute ‘array‘的主要内容,如果未能解决你的问题,请参考以下文章

python代码报错No module named numpy问题

opencv python 已经安装numpy 依然报错No module named 'numpy'和 No module named 'cv2'

【Ubuntu 虚拟机PyCharm配置问题】 No module named numpy 问题解决

错误记录Mac 中 IntelliJ IDEA 运行 Python 程序报错 ( No module named ‘numpy‘ )

numpy module not found 错误:通过cmd下载了两次,可能是因为我的系统中有两个版本的python

python 如何安装module