Python blender游戏引擎导入错误

Python blender游戏引擎导入错误,python,blender,Python,Blender,我刚开始学习blender及其脚本,并尝试运行其示例代码 import bge def main(): cont = bge.logic.getCurrentController() own = cont.owner sens = cont.sensors['mySensor'] actu = cont.actuators['myActuator'] if sens.positive: cont.activate(actu) else: cont.deactivate(

我刚开始学习blender及其脚本,并尝试运行其示例代码

import bge


def main():

cont = bge.logic.getCurrentController()
own = cont.owner

sens = cont.sensors['mySensor']
actu = cont.actuators['myActuator']

if sens.positive:
    cont.activate(actu)
else:
    cont.deactivate(actu)
main()
并获取以下错误: ImportError:没有名为“bge”的模块 我寻找了一个解决方案,但没有找到。如何解决这个问题?
我使用的是blender 2.65

当您按下“运行脚本”或试图在终端中发出此命令时,运行导入bge不起作用。您必须按“P”键才能激活游戏引擎模式。要运行脚本,请将控制器连接到脚本

  • 导入的“bge”必须是“blender game”,而不是blender渲染
  • 在“游戏逻辑编辑器”中提供“始终”运行python脚本
  • 开始比赛