Error deploying an app to streamlit. ModuleNotFoundError: No module named 'app'

I have a flask web app (machine learning app) already deployed and running on Heroku at: https://hedeya-disaster-response-app.herokuapp.com/

When I tried to deploy it to Streamlit, I got the following error:

File "/app/disaster-response-pipeline-project/app/run.py", line 21, in <module>

    from app.classDefs import ItemSelector, tokenize, StartingVerbExtractor, MessageLengthExtractor # Heroku

ModuleNotFoundError: No module named 'app'

Even when I tried to remove “app.” from the above mentioned line, I got another error.

Here is a link to the github repository: GitHub - hedeya1980/Disaster-Response-Pipeline-Project

Hi there @hedeya1980 ,

Assuming you were trying to deploy to Streamlit community cloud, keep in mind it only supports Streamlit apps (your app is not a Streamlit app).

If you do end up recreating it as a streamlit app, you will need to make a few changes.

  1. As you noticed, from app.classDefs doesn’t work – you will need to change this to from classDefs instead, since streamlit will be run from inside the app/ folder.
  2. Replace your flask routes with regular functions, and call them in the course of your streamlit app running.

You should be able to test it locally by going into the app/ folder and doing streamlit run run.py

1 Like

Hi @marduk,
Thanks for your reply.
I didn’t know this information. I’ll read about Streamlit apps.
Thanks a lot.

Hi @blackary ,
All noted with thanks.
I’ll read about Streamlit apps. I thought it’s possible to deply Flask apps, as with other deployment sites.
Thanks a lot.