Command-line arguments

First and foremost, amazing product. I ran a couple of the demos and am thoroughly impressed.

In a python script I want to run with streamlit, I have been trying to add command-line arguments. Whether through argparse or simply sys.argv, I keep getting “no such option”.

I had thought the example:
Usage: streamlit run [OPTIONS] FILE_OR_URL [ARGS]…

implied that ARGS were arguments for the python script, but that doesn’t seem to be the case. Do you (or anyone else) know whether adding command-line arguments to the streamlit script is possible? Or would I have to put them in a wrapper script that calls the streamlit script?


1 Like

I have noticed the same issue. According to the docs, you should be able to pass command line arguments to the script, but instead they are interpreted as arguments to streamlit.

1 Like

Hi @Dan and @zjorgensenbits

Right now you can only pass custom command-line arguments to streamlit run if those arguments don’t look like flags (i.e. they look like foo, not --foo).

This is because the module we use for parsing command-line arguments greedily interprets all arguments as belonging to Streamlit. So that module raises an error when it sees an argument doesn’t match one of our supported flags.

Needless to say, we’re looking into ways to address this!

In the meantime, is it possible to refactor your code support arguments without --? I know this is not optimal, but it’s the current work-around we have :confused:

Either way, please upvote the bug over here


Thank you very much for taking the time to respond, @thiago! Yes, I can easily drop the --. That was all I had tried to that point, so I wasn’t sure that I could use command-line arguments at all. Thanks again!
Dan McGonigle

1 Like

I’m a year late to this question but found it while googling “streamlit argparse” so thought I’d put a solution here. To stop streamlit from parsing farther you can add --

streamlit run -- --title blahblah

And if you wrap the streamlit run -- inside a bash script you could have something that looked even more consistent with normal command line options.


TypeError: init() got an unexpected keyword argument ‘show_envvar’

i am getting this error in my terminal while running my app through streamlit run… i was not getting any such error earlier and have not changed my code