Streamlit app works locally but not on Heroku

I have a stock prediction code using streamlit and fbprophet that is working locally, and when I deploy it on Heroku, it says deployed successfully but on going to the site I get the error

ModuleNotFoundError: No module named 'fbprophet.plot'
Traceback:
File "/app/.heroku/python/lib/python3.9/site-packages/streamlit/script_runner.py", line 338, in _run_script
    exec(code, module.__dict__)
File "/app/Stock-Prediction.py", line 8, in <module>
    from fbprophet.plot import plot_plotly

I have tried changing fbprophet to prophet but that does not work. Instead of this error, I get

ModuleNotFoundError: No module named 'prophet.plot'

Even while running the app locally, I was initially getting errors due to fbprophet till I ran it using Anaconda instead of CMD on a Windows system. It works with Anaconda only.
Procfile:

web: sh setup.sh && streamlit run Stock-Prediction.py

setup.sh:

mkdir -p ~/.streamlit/
echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml

requirements.txt:

streamlit==0.82.0
pandas==1.1.3
yfinance==0.1.59
fbprophet==0.2
plotly==4.14.3
pystan==2.19.1.1

While trying to solve this problem I added a packages.txt file containing:

gcc
g++
build-essential
python3-dev

This is the first time I am trying to deploy an app on Heroku. Any help would be greatly appreciated.

1 Like

Hi @Hansika_Sachdeva, welcome to the Streamlit community!! :clap: :partying_face:

The version of fbprophet in your requirements file on Heroku is fbprophet==0.2, which was released in 2017. In 2017, the package didnโ€™t contain the plot module and plot_plotly function.

I would suggest including a more updated version of the package in your requirements file.

Happy Streamlitโ€™ing! :balloon:
Snehan

Updating the version to 0.7.1 worked. Thank you!