Why does running a game engine script from the text editor cause an error? Why does running you Python script using "run script" option in text editor generate an error called "bge module not found", while executing it using P command doesn't cause any problems?
The 'Run Script' button is not intended for BGE, but for Blender addons and macros. Understand that BGE is a standalone component, it's not part of Blender environment.

This way, importing the module bge is not possible when running scripts inside Blender, the same way you can't import the module bpy while running scripts through BGE.