# Python command line arguments not being accepted

**URL:** <https://forums.unrealengine.com/t/python-command-line-arguments-not-being-accepted/425349>\
**Category:** Editor Scripting\
**Tags:** Python, unreal-engine, editor, UE4, question\
**Created:** [May 17, 2018, 5:47pm UTC](https://forums.unrealengine.com/t/python-command-line-arguments-not-being-accepted/425349 "2018-05-17T17:47:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4dba84ed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4dba84ed](https://forums.unrealengine.com/u/anonymous_user_4dba84ed)\
**Post date:** [May 17, 2018, 5:47pm UTC](https://forums.unrealengine.com/t/python-command-line-arguments-not-being-accepted/425349/1 "2018-05-17T17:47:15Z")

</div>

Hi,

I’m trying to read command line arguments using the following code

```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('vrscene', help='VRay Scene to process')
command_line_args = parser.parse_args()
print (command_line_args)

```

But i get a python error anytime I add anything at the end of the script invocation through the output log i.e ‘py myscript.py’ . If i try to execute ‘py myscript.py --vrscene test’ or ‘py myscript.py anytext’ i get a string error. Seems like its not accepting anything after the name of the script.

My end goal is to be able to supply command line args through command line invocation i.e 'UE4Editor-Cmd.exe myproject.uproject ExecutePythonScript=“myscript.py --vrscene test”

How can I do this ?

Thanks,

---

<div class="post-metadata">

**Author:** ![oktomus\_tuatara](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/oktomus_tuatara/32/613412_2.png) [@oktomus\_tuatara](https://forums.unrealengine.com/u/oktomus_tuatara)\
**Post date:** [January 31, 2023, 10:06am UTC](https://forums.unrealengine.com/t/python-command-line-arguments-not-being-accepted/425349/2 "2023-01-31T10:06:34Z")

</div>

You didn’t provide the correct settings to [`add_argument`](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument).

This work when being run from an Editor Blueprint inheriting from Editor Utility Actor, I guess it should work as well from the command line.

```plaintext
# Get raw arguments
import sys
unreal.log(f"Python command RAW arguments: {sys.argv}")

# Parse arguments
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--vrscene', help='VRay Scene to process')
args = parser.parse_args()
unreal.log(f"vrscene={args.vrscene}")

```

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/5/e156d95b92b6ded866d9eaebd5851ffc46396d0f.png)

```auto
# Output
LogPython: vrscene=test

```
