Python API, unreal 5.3, Enable in Shipping (Windows>DebugGame) ?

In unreal 5.3, I am finally able to use the python API. It works well in editor mode. That being said, for a couple of reasons, I want to enable python API in a packaged Debug version of my game.

In editor Play mode, I am able to launch my python scripts using an ‘Execute Console Log’ (Blueprint node) command with either:

-py hello_world.py (Works if my hello world is in Content/Python)
or
-py “C:.….…\Content\Python\hello_world.py” (absolute path OK)

However due to some hardware limitations and other aspects, I want to use the python API within a packaged (Windows>DebugGame) version of my game. To ease the process I don’t mind using absolute path to point to my script and even to point to my python .exe.

In a packaged (Windows>DebugGame) version of my game, I was not able to use ‘Execute Console Log’ (with relative and absolute path) so I tried with a cpp FProcHandle ProcessHandle = FPlatformProcess::CreateProc(…) with a .bat file to run and redirect output to a log.

With the .bat file approach, I can redirect echo cmds to file ‘echo BOB > “C:.…\MyFile” 2>&1’ but can’t do it for python file (File created but always 0 Kb). If I cheat and force a python window to open, I can see it use the engine python as desired but the ‘import unreal’ is not recognized as it normally does when I run from the editor.

QUESTION: How to easily use the python API in unreal 5.3 within a packaged (Windows>DebugGame) version of my game? If possible, provide an hello_world.py example that uses the ‘import unreal’ and ‘unreal.log(…)’

Note1: Don’t focus on how to ship the python env for now, I don’t mind using my engine python.

Note2: What I really want in the end, is a mean to use the ‘import unreal’ in a python script with a packaged (Windows>DebugGame) version of my game so I have a powerful way to easily access the actors states in my game. I tried socket approach but having tested the python API in editor play mode I would really prefer this approach.

It seems like the python API is meant for editor purpose :expressionless: . Screw it I have way more control with sockets and my game is more fluid with the socket approach