简体   繁体   English

使用非常简单的脚本导入numpy时出错

[英]Error when importing numpy with a very simple script

I am receiving the following error when running a simple code which is the following: 运行以下简单代码时,我收到以下错误:

import numpy as np

N = 10

diagonal = np.zeros(N) + 2

print diagonal

Error: 错误:

Traceback (most recent call last):
  File "diagonalmatrix.py", line 1, in <module>
    import numpy as np
  File "/Users/jamesmalone/Documents/Python/Coursework/numpy.py", line 5, in <module>
    diagonal = np.zeros(N) + 2
AttributeError: 'module' object has no attribute 'zeros'

There is a numpy.py file in your current working directory . 当前工作目录中有一个numpy.py文件。 You need to rename it with some other name and then try again. 您需要使用其他名称重命名它,然后重试。 The thing is this file is getting imported rather than original numpy module. 问题是此文件将被导入,而不是原始的numpy模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM