为什么最简单的 streamlit 示例会出错?

Why does the simplest streamlit example errors out?

我有最简单的streamlit程序

# import module
import streamlit as st

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

当我运行代码使用

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'

我错过了什么?

刚运行陷入同样的​​问题。似乎与 click 软件包的最新版本有关。

如果卸载click:

pip uninstall click

然后安装最新版本之前的版本:

pip install click==8.0.4

它应该会再次工作。

回退点击包的版本。当我 re-cloned 我们的 repo 并安装依赖项时,它更新了 click 到 8.1.0 并且一切都死了。我卸载了它,重新安装了 8.0.4,它 运行 很好。检查您的点击版本。显然,get_os_args 函数已被删除并且无法与 streamlit 一起使用。