# UE4Editor-Cmd.exe python script with spaces in path

**URL:** <https://forums.unrealengine.com/t/ue4editor-cmd-exe-python-script-with-spaces-in-path/527233>\
**Category:** Platform & Builds\
**Tags:** Console, unreal-engine, UE4-27, question\
**Created:** [April 13, 2022, 3:11pm UTC](https://forums.unrealengine.com/t/ue4editor-cmd-exe-python-script-with-spaces-in-path/527233 "2022-04-13T15:11:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaximeSainlot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MaximeSainlot](https://forums.unrealengine.com/u/MaximeSainlot)\
**Post date:** [April 13, 2022, 3:11pm UTC](https://forums.unrealengine.com/t/ue4editor-cmd-exe-python-script-with-spaces-in-path/527233/1 "2022-04-13T15:11:42Z")

</div>

There is a space in the path to my python script. I feel like I’ve tried everything for escaping these spaces (Linux and Windows style escapes using backslashes, ^, and all sorts of quotes and quote escapes). The command runs fine when the path as no space in it. Here’s the command used :

`"C:\Program Files\Epic Games\UE_4.27\Engine\Binaries\Win64\UE4Editor-Cmd.exe" "path\to\myproject.uproject" -stdout -FullStdOutLogOutput -run=pythonscript -script="C:\path with spaces\to\my\script.py" | FINDSTR "LogPython"`

Depending on the style of escaping I either get :

- `Error: SyntaxError: unexpected character after line continuation character (<string>, line 1)`

- `Error: SyntaxError: invalid syntax (<string>, line 1)`

- `Error: -Script argument not specified`

Some of the path style I’ve tried :

- `"C:\\path\ with\ spaces\\to\\my\\script.py"`

- `"C:/path with spaces/to/my/script.py"`

- `\"C:\path with spaces\to\my\script.py\"`

- `C:\path^ with^ spaces\to\my\script.py`

- `" 'C:/path with spaces/to/my/script.py' "`

- multiple combination of those

The [community wiki](https://unrealcommunity.wiki/command-line-interface-cli-3mcqmc4z) mentions this in the pitfall section but without explaining the fix.

Other useful ressources : [Unreal doc](https://docs.unrealengine.com/5.0/en-US/scripting-the-unreal-editor-using-python/#thecommandline)

Thanks a lot for any insight.

---

<div class="post-metadata">

**Author:** ![Guohoucheng1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Guohoucheng1](https://forums.unrealengine.com/u/Guohoucheng1)\
**Post date:** [December 14, 2023, 7:27am UTC](https://forums.unrealengine.com/t/ue4editor-cmd-exe-python-script-with-spaces-in-path/527233/2 "2023-12-14T07:27:51Z")

</div>

// The code needs to manage spaces and quotes. The scripts pathname and the script arguments are passed to the ‘PY’  
// command which are passed to Python plugin for execution. Below shows how to quotes the script pathname  
// and the scripts arguments when they contain spaces.  
// ±----------------------------------------------------------------------------------±--------------------------------------------------+  
// | Command Line Parameters | Resulting “PY” command |  
// ±----------------------------------------------------------------------------------±--------------------------------------------------+  
// | -ExecutePythonScript=script.py | PY script.py |  
// | -ExecutePythonScript=“script.py” | PY script.py |  
// | -ExecutePythonScript=“C:/With Space/with space.py” | PY C:/With Space/with space.py |  
// | -ExecutePythonScript=“script.py arg1” | PY script.py arg1 |  
// | -ExecutePythonScript=“script.py arg1 \"args with space\"” | PY script.py arg1 “args with space” |  
// | -ExecutePythonScript=“C:\With Space\with space.py \"arg with space\"” | PY C:/With Space/with space.py “arg with space” | NOTE: The Python plugin parses up the “.py” and manages the spaces in the pathname.  
// | -ExecutePythonScript=“\"C:/With Space/with space.py\" \"arg with space\"” | PY “C:/With Space/with space.py” “arg with space” |  
// ±----------------------------------------------------------------------------------±--------------------------------------------------+

–Hey, guys, there’s instructions in the source code
