Why does the simplest streamlit example errors out?
Asked Answered
L

2

5

I have the simplest streamlit program

# import module
import streamlit as st

# Title
st.title("Hello GeeksForGeeks !!!")

When I run the code using

streamlit run main.py, I get the following errors:

    SDRRAZAVIPOUR-MAC:[~/PycharmProjects/tool]$ streamlit run main.py
Traceback (most recent call last):
  File "/opt/miniconda3/envs/tool/bin/streamlit", line 8, in <module>
    sys.exit(main())
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/streamlit/cli.py", line 204, in main_run
    _main_run(target, args, flag_options=kwargs)
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/streamlit/cli.py", line 232, in _main_run
    command_line = _get_command_line_as_string()
  File "/opt/miniconda3/envs/tool/lib/python3.10/site-packages/streamlit/cli.py", line 221, in _get_command_line_as_string
    cmd_line_as_list.extend(click.get_os_args())
AttributeError: module 'click' has no attribute 'get_os_args'

What am I missing?

Logjam answered 28/3, 2022 at 18:32 Comment(0)
T
3

Roll back the version of the click package. When I re-cloned our repo and installed the dependencies, it updated click to 8.1.0 and everything died. I uninstalled it, reinstalled 8.0.4, and it ran fine. Check your version of click. Apparently, the get_os_args function has been removed and is not working with streamlit.

Thorton answered 28/3, 2022 at 22:9 Comment(0)
U
6

Just ran into the same problem. Seems to be related to the most recent version of the click package.

If you uninstall click:

pip uninstall click

and then install the version before the most recent one:

pip install click==8.0.4

it should work again.

Unhandsome answered 28/3, 2022 at 22:2 Comment(1)
Added a click==8.0.4 inside the requirements.txt for a deployment with Heroku. Worked like a charm.Pharos
T
3

Roll back the version of the click package. When I re-cloned our repo and installed the dependencies, it updated click to 8.1.0 and everything died. I uninstalled it, reinstalled 8.0.4, and it ran fine. Check your version of click. Apparently, the get_os_args function has been removed and is not working with streamlit.

Thorton answered 28/3, 2022 at 22:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.