Runtime EXE created by Blender unable to access Blender Python API

Hi,

I’ve been spending hours trying to get this done, but still haven’t found any solution:

I have created a Phython script, “test.py” in Blender:

import sys

import Blender

from Blender import Window

print GameLogic.getCurrentController()

print Window.GetScreenSize()

I have set the sensor for my camera to cause a controller to run “test.py” on pressing the “W” key.

If I run the game within the Blender GUI, everything works fine, the two prints you can see in the script are made to the Python console.

However, once I save the game as runtime, the console prints an error of “ImportError: No module named Blender”. For some strange reason, the “GameLogic.getCurrentController()” gets printed even by the EXE, while the “Window.GetScreenSize()” doesn’t, since the Blender.Window module could not be imported for the latter.

How can this be? I was hoping that Blender would create an EXE smart enough to hold ALL the necessary Python API modules, the Blender Game Logic API, AND the Blender API for python?

I need to be able to read the current size of the display window.

I am using Python 2.6, Blender 2.49b (also tried the 2.49), have also copied all the necessary DLLs into the EXE directory, registered the test.py in the TEXT node of the .blend file database…

What else could be the problem? Can the Blender Pyhton API be used in an Runtime EXE at all?

Thanks in advance.

Marvin

Well, no idea anyone?

Well, meanwhile I have managed to get the screen size through the GameLogic modules instead (using the Rasterizer.getWindowWidth() and Rasterizer.getWindowHeight()). It seems to me that everything really needed can be programmed without the Blender Python API, but with only the Blender GameLogic Python API.

Yes, exactly. Everything should be available through gamelogic and mathutils.

It should be stated more clear someplace, but the rule is don’t use the Blender module from within a game.