Home > Net >  pdm-installed streamlit fails to launch a server
pdm-installed streamlit fails to launch a server

Time:03-26

I have installed streamlit on my Mac with Safari Error Message: Rejected Connection

I tried switching to Brave Browser and Firefox, but I got the same error.

From other SO questions, I tried the following:

❯ 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

I also ran this:

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

I tried launching other stuff that creates a local server, e.g. Jupyter Notebooks, and they work.

CodePudding user response:

The problem is known: streamlit does not support pdm at the time of writing, as mentioned by @cye18 on the parallel issue opened on pdm's github page.

The problem is that, while streamlit configs default to server port 8501, the server is launched on the port 3000. You can force this behaviour in two ways.

The first is by manually changing streamlit's settings, which lies in ~/.streamlit/config.toml or locally in your project directory.

[server]
serverPort = 8501

Alternatively, you can add the following flag to the streamlit command when launching it:

pdm run streamlit run app.py --server.port 8501

Either way, streamlit will complain by saying that server.port does not work when global.developmentMode is true. Once again, this can be solved by adding the flag --global.developmentMode false. The final command will look like this: pdm run streamlit run app.py --server.port 8501 --global.developmentMode false.

Alternatively, the local settings will look like the following:

[server]
port = 8501

[global]
developmentMode = false
  • Related