该报错原因是引用了 numpy 模块,但是 numpy 模块不存在 array 属性导致的。
下面是解决办法的完整攻略:
- 确认 numpy 安装
在终端中输入以下命令:
pip show numpy
如果没有安装 numpy,则需要先进行安装,可以通过以下命令进行安装:
pip install numpy
- 引入 numpy 模块
在代码文件的开头,需要添加以下语句引入 numpy 模块:
import numpy as np
- 使用正确的 numpy 函数
使用 numpy 数组时,需要使用 numpy 中的 array 函数,例如:
a = np.array([1,2,3])
以上是解决 “AttributeError: ‘module’ object has no attribute ‘array'” 的完整攻略,希望能帮助到你。