Configuration配置
config.toml
config.toml 是一个可选文件,你可以为工作目录或全局开发环境定义它。当 config.toml 文件同时在全局和工作目录中定义时,Streamlit 会合并配置选项,并优先使用工作目录配置。此外,你还可以使用环境变量和命令行选项来覆盖其他配置选项。更多信息,请参阅配置选项。
文件位置
要在本地或按项目定义配置,请将 .streamlit/config.toml 添加到工作目录。您的工作目录就是您调用 streamlit 运行的地方。如果之前未创建 .streamlit 目录,则需要添加该目录。
要全局定义配置,必须先找到全局 .streamlit 目录。在安装过程中,Streamlit 会将此隐藏目录添加到操作系统的用户配置文件中。对于 MacOS/Linx,该目录为 ~/.streamlit/config.toml。对于 Windows,则是 %userprofile%/.streamlit/config.toml。
文件格式
config.toml 是一个 TOML 文件。
代码
[client]
showErrorDetails = false
[theme]
primaryColor = "#F63366"
backgroundColor = "black"
可用的配置选项
以下是 .streamlit/config.toml 文件中的所有部分和选项。要查看所有配置,请在终端或 CLI 中使用以下命令:
streamlit config show
全局global
[global]
# ***DEPRECATED***
# global.disableWatchdogWarning has been deprecated and will be removed in a
# future version. This option will be removed on or after 2024-01-20.
# ****************
# By default, Streamlit checks if the Python watchdog module is available
# and, if not, prints a warning asking for you to install it. The watchdog
# module is not required, but highly recommended. It improves Streamlit's
# abilit