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?
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.
Right now you can only pass custom command-line arguments to streamlit run yourscript.py 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
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
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 --
example: streamlit run perfviz_streamlit.py -- --title blahblah
And if you wrap the streamlit run perfviz_streamlit.py -- 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
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.