我已经在Mac上安装了streamlit
和pdm
,并启动了streamlit hello
命令来查看演示。该命令返回以下内容:
❯ 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时,连接被拒绝:
的数据
我试着切换到勇敢浏览器和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 Notebooks,它们可以工作。
1条答案
按热度按时间3htmauhk1#
问题是已知的:
streamlit
does not supportpdm
在写入时,as mentioned by @cye18 on the parallel issue opened on pdm's github page。问题是,虽然
streamlit
默认配置为服务器端口8501
,但服务器在端口3000
上启动。您可以通过两种方式强制执行此行为。第一种方法是手动更改streamlit的设置,它位于
~/.streamlit/config.toml
or locally in your project directory中。字符串
或者,您可以在启动
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.
个或者,本地设置如下所示:
型