Python:“NameError:未定义全局名称'arrow'”

2024-06-16 12:35:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Python的初学者,我尝试运行以下代码: http://www.physics.orst.edu/~rubin/Books/eBookWorking/html/Ising.html

当我试图执行此代码时,出现以下错误:

Traceback (most recent call last):
  File "C:\simulations\ising\ising.py", line 53
    spstate(state)                      # plots initial state: all spins down
  File "C:\simulations\ising\ising.py", line 47, in spstate
    arrow(pos=(i,ypos,0), axis=(0,5*state[j],0), color=arrowcol)
NameError: global name 'arrow' is not defined

这很奇怪,因为箭头应该是VPython的函数: http://www.vpython.org/contents/docs/arrow.html

我在ubuntu12.04中用wine和VIDLE VPython运行这个。在

如果我从Ubuntu本地运行这段代码,它仍然不能执行,但是错误消息是不同的:

^{pr2}$

由于我不太熟悉Python编程和错误消息,我有点迷茫了,不知道从哪里开始寻找错误的根源。在


Tags: 代码pyhttp消息htmlwww错误line