That's all you need to get started running UE4 Python scripts from the commandline.
Here's an example of the full command put together: "C:\Program Files\Epic Games\UE_4.25\Engine\Binaries\Win64\UE4Editor-Cmd.exe" "C:\Path\To\Project.uproject" -stdout -FullStdOutLogOutput -ExecutePythonScript="C:\Path\To\do_import.py C:\Path\To\model.fbx /Game/MyProject/Level/Test" Conclusion
It was tricky to find these flagsm but without these, you won't be able to see your print statements or Python error output. # Result: C:\\Path\\To\\model.fbx Helpful Flagsįor easier debugging while working on your script, I recommend using "-stdout" and "-FullStdOutLogOutput". # sys.argv and onward gives you access to your scripts arguments. # This is the script file you're running. The arguments can be accessed with sys.argv. However, if anyone could run it, that person would be you, as you have a pretty beastly setup. There are only videos of the engine being run. Once you have UE4 calling your script, you can access the arguments the same way you would when you execute a Python script with a standard python interpreter. We don't know what Unreal Engine 4 will take to run there's not any way for the general population to 'run' UE4 right now. From what I've found, there isn't a reliable way to run a Python script in headless mode at this time, but you can still use this approach to run scripts unsupervised. Note that this will open the UE4Editor, run the script, and close the UE4Editor automatically. Open the Epic Launcher client, and select the Unreal Engine tab. I'm using quotes around the UE4Editor-Cmd.exe and also the project path so that I don't need to worry about escaping the backslashes on Windows. Here's an example of what the command might look like for an FBX import script: "C:\Program Files\Epic Games\UE_4.25\Engine\Binaries\Win64\UE4Editor-Cmd.exe" "C:\Path\To\Project.uproject" -ExecutePythonScript="C:\Path\To\do_import.py C:\Path\To\model.fbx /Game/MyProject/Level/Test" One detail to note is that the Python script arguments are all part of the "-ExecutePythonScript" argument so I encapsulate them along with the script path in quotes to pass them in together. Here's a template explaining what the command should look like: -ExecutePythonScript=" "
This approach works great for running scripts for projects offline or even batching work for a project you currently have open. While the UE4 documentation lists a few different ways to run Python scripts, the approach I'll be going over has given me the most consistent results. You can run Unreal Engine Python scripts from the commandline to pipeline UE4 with other apps or automate repetitive tasks for your projects.