Running a Python script with c++

PythonBridge.generated.h is not something that exists as source code, it’s an intermediate header that’s being “generated” during compilation.

I wanted to share a simple solution that wasn’t mentioned here. What I use to execute a simple one-liner Python commands is by using the IPythonScriptPlugin::ExecPythonCommand, i.e.

FString Command = TEXT("print('Hello World')");
IPythonScriptPlugin::Get()->ExecPythonCommand(*Command);

Just make sure to #include "IPythonScriptPlugin.h" and add the PythonScriptPlugin module to private dependencies.

1 Like