Problem
Perhaps your app is working fine locally but when you’ve deployed the app it is no longer working. This is a common scenario encountered by users; let’s take a look at how we can resolve this.
Solution
Scenario 1: Discrepancy of library version of those used locally vs. cloud
In most cases, this issue is most likely caused by a discrepancy in the library version of those installed locally vs. installed on the cloud.
This can be solved by making sure that the library version that is used on the cloud is the same as that installed locally.
For example, if you’re using numpy
version 1.26.0 locally and if you’re specifying only numpy
in your requirements.txt
file then this would most likely lead to the server automatically using the latest version instead of the older version used by your app when it was created.
Typically, library dependencies may change over time and therefore it is always a great idea to pin a specific version in your requirements.txt
file. Thus, you can instead specify numpy==1.26.0
in your requirements.txt
file.
Scenario 2: Missing library dependencies
Another plausible explanation is that your deployed app may be missing dependent libraries. Perhaps the library is installed locally but is missing in the cloud deployment.
To figure out which libraries are missing, you can look at the imported libraries in your streamlit_app.py
file and make sure to include them in your requirements.txt
file.
For example if your app has import statements such as:
import streamlit as st
import pandas as pd
import numpy as np
Please ensure that you have streamlit
, pandas
and numpy
in your requirements.txt
file like so:
streamlit==1.38.0
pandas==2.2.2
numpy==2.1.0