How to setup a simple scene using Python in BGE?
ShungChing!

This problem is due to the fact that you are using the wrong library. When you use Blender Game Engine, you have to use bge library instead of bpy. 
Try to do the next things:
1) Add an empty in the position you wan to add cube;

2) Add the cube to another layer;

3) To Empty object attach the always sensor --> python controller --> EditObject actuator(make the actuator's name is 'AddCube')

4) The script:

import bge
from bge import logic, types

cont = logic.getCurrentController()
act = cont.actuators["AddCube"]
act.instantAddObject()


Answer files