pdm 安装的 streamlit 无法启动服务器
pdm-installed streamlit fails to launch a server
我已经使用 pdm
在我的 Mac 上安装了 streamlit
并启动命令 streamlit hello
来查看演示。命令returns如下:
❯ pdm run streamlit hello
2022-03-21 11:43:45.812 WARNING streamlit.config:
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.
More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2022-03-21 11:43:45.816 DEBUG streamlit.logger: Initialized tornado logs
2022-03-21 11:43:45.818 DEBUG matplotlib.pyplot: Loaded backend agg version unknown.
2022-03-21 11:43:45.819 DEBUG streamlit.bootstrap: Setting up signal handler
2022-03-21 11:43:45.819 DEBUG asyncio: Using selector: KqueueSelector
2022-03-21 11:43:45.827 DEBUG streamlit.server.server: Starting server...
2022-03-21 11:43:45.827 DEBUG streamlit.server.server: Serving static content from the Node dev server
2022-03-21 11:43:45.830 DEBUG streamlit.server.server: Server started on port 8501
2022-03-21 11:43:45.831 DEBUG streamlit.server.server: Server state: State.INITIAL -> State.WAITING_FOR_FIRST_BROWSER
2022-03-21 11:43:46.029 DEBUG git.cmd: Popen(['git', 'version'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
2022-03-21 11:43:46.041 DEBUG git.cmd: Popen(['git', 'version'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
2022-03-21 11:43:46.054 DEBUG git.cmd: Popen(['git', 'version'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
2022-03-21 11:43:46.066 DEBUG git.cmd: Popen(['git', 'rev-parse', '--show-toplevel'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
Welcome to Streamlit. Check out our demo in your browser.
Local URL: http://localhost:3000
Network URL: http://192.168.1.117:3000
Ready to create your own Python apps super quickly?
Head over to https://docs.streamlit.io
May you create awesome apps!
但是,当我连接到本地URL时,连接被拒绝:
我尝试切换到 Brave Browser 和 Firefox,但我遇到了同样的错误。
根据其他 SO 问题,我尝试了以下方法:
❯ apachectl configtest
AH00557: httpd: apr_sockaddr_info_get() failed for Lucas-MacBook-Air.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
我也运行这个:
ps -ax | grep 'httpd'
124 ?? 0:00.85 /usr/sbin/httpd -D FOREGROUND
517 ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
6627 ttys002 0:00.01 grep httpd
我尝试启动其他创建本地服务器的东西,例如Jupyter 笔记本,它们可以工作。
问题已知:streamlit
does not support pdm
at the time of writing, as mentioned by @cye18 on the parallel issue opened on pdm's github page.
问题是,虽然 streamlit
配置默认为服务器端口 8501
,但服务器在端口 3000
上启动。您可以通过两种方式强制执行此行为。
第一个是手动changing streamlit's settings, which lies in ~/.streamlit/config.toml
or locally in your project directory。
[server]
serverPort = 8501
或者,您可以在 streamlit
命令启动时添加以下标志:
pdm run streamlit run app.py --server.port 8501
无论哪种方式,streamlit
都会抱怨说 server.port does not work when global.developmentMode is true
。再一次,这可以通过添加标志 --global.developmentMode false
来解决。最终命令将如下所示:pdm run streamlit run app.py --server.port 8501 --global.developmentMode false.
或者,本地设置如下所示:
[server]
port = 8501
[global]
developmentMode = false
我已经使用 pdm
在我的 Mac 上安装了 streamlit
并启动命令 streamlit hello
来查看演示。命令returns如下:
❯ pdm run streamlit hello
2022-03-21 11:43:45.812 WARNING streamlit.config:
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.
More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2022-03-21 11:43:45.816 DEBUG streamlit.logger: Initialized tornado logs
2022-03-21 11:43:45.818 DEBUG matplotlib.pyplot: Loaded backend agg version unknown.
2022-03-21 11:43:45.819 DEBUG streamlit.bootstrap: Setting up signal handler
2022-03-21 11:43:45.819 DEBUG asyncio: Using selector: KqueueSelector
2022-03-21 11:43:45.827 DEBUG streamlit.server.server: Starting server...
2022-03-21 11:43:45.827 DEBUG streamlit.server.server: Serving static content from the Node dev server
2022-03-21 11:43:45.830 DEBUG streamlit.server.server: Server started on port 8501
2022-03-21 11:43:45.831 DEBUG streamlit.server.server: Server state: State.INITIAL -> State.WAITING_FOR_FIRST_BROWSER
2022-03-21 11:43:46.029 DEBUG git.cmd: Popen(['git', 'version'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
2022-03-21 11:43:46.041 DEBUG git.cmd: Popen(['git', 'version'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
2022-03-21 11:43:46.054 DEBUG git.cmd: Popen(['git', 'version'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
2022-03-21 11:43:46.066 DEBUG git.cmd: Popen(['git', 'rev-parse', '--show-toplevel'], cwd=<my/working/directory>, universal_newlines=False, shell=None, istream=None)
Welcome to Streamlit. Check out our demo in your browser.
Local URL: http://localhost:3000
Network URL: http://192.168.1.117:3000
Ready to create your own Python apps super quickly?
Head over to https://docs.streamlit.io
May you create awesome apps!
但是,当我连接到本地URL时,连接被拒绝:
我尝试切换到 Brave Browser 和 Firefox,但我遇到了同样的错误。
根据其他 SO 问题,我尝试了以下方法:
❯ apachectl configtest
AH00557: httpd: apr_sockaddr_info_get() failed for Lucas-MacBook-Air.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
我也运行这个:
ps -ax | grep 'httpd'
124 ?? 0:00.85 /usr/sbin/httpd -D FOREGROUND
517 ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
6627 ttys002 0:00.01 grep httpd
我尝试启动其他创建本地服务器的东西,例如Jupyter 笔记本,它们可以工作。
问题已知:streamlit
does not support pdm
at the time of writing, as mentioned by @cye18 on the parallel issue opened on pdm's github page.
问题是,虽然 streamlit
配置默认为服务器端口 8501
,但服务器在端口 3000
上启动。您可以通过两种方式强制执行此行为。
第一个是手动changing streamlit's settings, which lies in ~/.streamlit/config.toml
or locally in your project directory。
[server]
serverPort = 8501
或者,您可以在 streamlit
命令启动时添加以下标志:
pdm run streamlit run app.py --server.port 8501
无论哪种方式,streamlit
都会抱怨说 server.port does not work when global.developmentMode is true
。再一次,这可以通过添加标志 --global.developmentMode false
来解决。最终命令将如下所示:pdm run streamlit run app.py --server.port 8501 --global.developmentMode false.
或者,本地设置如下所示:
[server]
port = 8501
[global]
developmentMode = false