Python错误集锦: NameError: name ‘numpy’ is not defined

原文链接:http://www.juzicode.com/archives/2225

错误提示:

使用numpy.eye()函数时报NameError: name ‘numpy’ is not defined

D:\juzicode>python mod.py
 微信公众号: 桔子code / juzicode.com
 Traceback (most recent call last):
   File "mod.py", line 3, in 
     n = numpy.eye(4)
 NameError: name 'numpy' is not defined

Python错误集锦: NameError: name ‘numpy’ is not defined

可能原因:

1、没有导入numpy模块,使用了numpy模块中的函数。

 

解决方法:

1、在调用numpy的函数前,导入模块numpy:

Python错误集锦: NameError: name ‘numpy’ is not defined

上一篇:SpringBoot 管理引起的冲突


下一篇:A Genetically Defined Compartmentalized Striatal Direct Pathway for Negative Reinforcement