Python modules not found

Hello all,

I am new to Blender and VERY new to Python, so forgive me if this question seems too basic.

I am trying to run a script that is included in the Blender Gamekit tutorials, and includes the following code:

import GameLogic
5 def ranint(min,max):
6 return(int(GameLogic.getRandomFloat()*(max+1-min)+min))
8 contr = GameLogic.getCurrentController()
9 owner = contr.getOwner()
10 key = contr.getSensor(“mixitbaby”)
11 near = contr.getSensor(“near”)
12 mess = contr.getActuator(“shuffled”)
14 # collects all gongs
15 objs=near.getHitObjectList()
17 owner.shuffle = owner.shuffle - 1
18 if owner.shuffle<0:
19 GameLogic.addActiveActuator(mess,1)
20 else:
21 g1 = ranint(0,19)
22 g2 = ranint(0,19)
24 pos1 = objs[g1].getPosition()
25 pos2 = objs[g2].getPosition()
26 objs[g1].setPosition(pos2)
27 objs[g2].setPosition(pos1)

The script is failing with the following error:

“ImportError: No module named GameLogic”

I suspected that this had something to do with how my environment variables were set, so I set my PYTHONPATH variable to the following, but it did not help:


So, I am at a loss. Can someone explain this to me?



The scripts that use GameLogic must be run with a Python controller from within a game (not with alt-p).

Ahhh… that makes sense. Works like a charm when I do that. Thanks!