Streamlit App does not deploy

My python streamlit app works correctly when I run the code myself. However when I deploy it, it continuously gives the following error on the promote stage. I’ve tried doing all kinds of deployments (Static, Autoscale and Reserved).

exec [sh -c python3 main.py] error=exec: already started
      Email:  
2024-02-14T12:00:14Z error: The deployment failed to initialize due to a configuration or code error. Check the logs tab for more information. For additional support, please post on https://ask.replit.com/c/help/13 and a staff member will take a look.

My app is a chatbot that references openai for responses.

Hi @rameezpak1000 , welcome to the forums!
Just to confirm, does your repl has a webserver?
If so, try deploying it as Autoscale, and send the full Logs of the deployment.
Thanks!

Hi, here are the logs from an autoscale deployment

2024-02-14T12:11:01Z info: Deployment: 6d82d738-e5da-46bc-9363-e66bda7b133b
2024-02-14T12:11:01Z info: Build: 0f95f906-668a-4dfe-9a95-6724ad3255a9
2024-02-14T12:11:01Z info: Connecting to builder
2024-02-14T12:11:04Z info: Builder connected
2024-02-14T12:11:06Z info: Installing packages
2024-02-14T12:11:07Z info: Skipping Build as no Build command set
2024-02-14T12:11:07Z info: Pushing pid1 binary layer...
2024-02-14T12:11:11Z info: Skipping Python layer creation
2024-02-14T12:11:11Z info: Skipping Node layer creation
2024-02-14T12:11:11Z info: Pushing Repl layer...
2024-02-14T12:11:11Z info: Pushing hosting layer...
2024-02-14T12:11:12Z info: Retrieved cached nix layer
2024-02-14T12:11:12Z info: Created hosting layer
2024-02-14T12:11:13Z info: Created pid1 binary layer
2024-02-14T12:12:07Z info: Created Repl layer
2024-02-14T12:12:09Z info: Pushed image manifest
2024-02-14T12:12:10Z info: Pushed soci index manifest
2024-02-14T12:12:17Z info: Creating Autoscale service
starting up user application

      leave this field blank.
exec [sh -c python3 main.py] error=exec: already started

      and the occasional swag, please enter your email address below. Otherwise,
      If you’d like to receive helpful onboarding emails, news, offers, promotions,
2024-02-14T12:13:07Z error: The deployment failed to initialize due to a configuration or code error. Check the logs tab for more information.

Hi @rameezpak1000 !
In your .replit file, try changing the run variable under [deployment] to:

run = ["python3", "main.py"]

Hope this helps!

Hey, it still gave the same error.

For reference, my main.py only has the following code in it:

import os

os.system("streamlit run dataquartz_bot.py")

whereas the dataquartz_bot.py file has all the code for the streamlit application, in case that helps in any debugging.

In that case, wouldn’t that be your deployment command?

it could be but running python3 main.py should also execute the same thing no?

Not sure, perhaps it’s causing an error when called indirectly like that?

that shoulnd’t be the issue, however I do notice one thing… when I click on Run to test my application streamlit prompts me for an email address, which obviously requires a manual answer in the shell. Could it be that no response here is causing the issue? Since when I enter my email or leave it blank and press enter, my application runs fine. but in deployment we dont have the option to

You’ll have to do some kind of workaround then, you can’t type into deployment shells.

I had the same error and fixed it using this -

https://docs.replit.com/hosting/deployments/troubleshooting#deploying-streamlit-applications