Skip to content
Notes
GitHub

Streamlit 启动时 OSError

streamlit 基本使用

使用命令安装

Terminal window
pip install streamlit
Terminal window
pip install streamlit

创建一个应用 app.py

import streamlit as st
st.title('My App')
user_input = st.text_input('Your name')
if user_input:
st.write(f'Hello, {user_input}')
import streamlit as st
st.title('My App')
user_input = st.text_input('Your name')
if user_input:
st.write(f'Hello, {user_input}')

运行

Terminal window
streamlit run app.py
Terminal window
streamlit run app.py

报错处理

Terminal window
OSError: [Error 28] inotify watch limit reached
Terminal window
OSError: [Error 28] inotify watch limit reached

这个错误通常发生在 Linux 中,当 inotify 实例数量超过系统限制时就会出现这个问题。

临时更改

Terminal window
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Terminal window
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

永久更改

/etc/sysctl.conf 中添加

Terminal window
fs.inotify.max_user_watches=524288
Terminal window
fs.inotify.max_user_watches=524288

运行下面的命令以生效

Terminal window
sudo sysctl -p
Terminal window
sudo sysctl -p