使用numpy'模块'对象没有属性'数组' [英] Using numpy 'module' object has no attribute 'array'
本文介绍了使用numpy'模块'对象没有属性'数组'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想像这样将列表转换为一维数组:
I am just trying to convert a list to a 1D array like so:
import numpy as np
print np.array([2, 3, 4])
但是出现以下错误:
Traceback (most recent call last):
File "numpy.py", line 11, in <module>
test_run()
File "numpy.py", line 8, in test_run
print np.array([2, 3, 4])
AttributeError: 'module' object has no attribute 'array'
我尝试重新安装numpy,因为这似乎对其他人有用,但这不能解决问题.
I tried reinstalling numpy because that seems to have worked for others, but this does not fix the problem.
推荐答案
您很可能在工作目录中有一个名为numpy.py的文件,该文件遮盖了真正的numpy模块.重命名该文件并删除其numpy.pyc文件.
You are most likely having a file called numpy.py in your working directory which shadows the real numpy module. Rename that file and remove its numpy.pyc file.
这篇关于使用numpy'模块'对象没有属性'数组'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文