No module named "bge" error

I’m trying to do a beginner Blender Game tutorial here: https://www.youtube.com/watch?v=g8RM8innhCY&list=PLQL0TBLSW4eD3lFSfEqTg_wJxIhHrHnT-&index=3 He imports bge (Blender Game Engine) at the beginning of the script. But when I run the script, I get an error message in the console telling me “No module named bge.”
Can someone tell me what I am doing wrong?


Blend file: http://pasteall.org/blend/index.php?id=48038

The problem is that the blender game engine (bge) environment (bgee?) doesn’t exist until the player is running. So, you can’t just execute game code like you would another script. Instead, link it in the game logic editor, and then press P to play the game:

I did what you said and I didn’t get an error message. In the tutorial, I suppose he assumed everyone would know what to do when he said to play the game to check for errors. Thanks.

But when I press p to play, I can’t use the keyboard to move the ball as he does in the tutorial. And he has the controllers in the logic editor set to module and PlayerScript.playerMovement.

Any ideas on how I can get the wsda and arrow keys to work in the game after I press p?


up at the top bar, “Window” then “Toggle System Console”.

show us whats in that little box that comes up.

I don’t know what you did, but in the Text editor, the script name was some nonsense, I would recommend you to take a look at it in the file you shared with us, it was a very weird name.

Then in the logic panel, the Python controller was refering to something like “PlayerScript.mainMovement” or whatever, this means that you needed a Python module named “PlayerScript.py” and a function “mainMovement” in there (the names are not the one used, but you get the point).

This and there was a typo, you wrote “locig” instead of “logic” somewhere.

Fixed: https://drive.google.com/open?id=0B_vMzUtLDf7VeGtEbTMtRnExYlk

Good luck spotting the next errors, you should learn where to look quickly, this will help you greatly.
The most common thing are typos, so when you have an error, look closely at the Console.
Its not just hacker type things, the error message is often self-explanatory, and usually a line number is provided, you might want to look around the line and not tunnel vision on it tho.

The tutorial is too advanced for me. Thanks for your responses anyway.