码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-04-27 18:01:42      阅读:14226      评论:0      收藏:0      [点我收藏+]

标签:call   numpy   tee   问题   style   百度   attr   recent   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‘

标签:call   numpy   tee   问题   style   百度   attr   recent   array   

原文地址:https://www.cnblogs.com/OliverQin/p/8963307.html

(4)
(19)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!