Error when deploy the app

Helle everyone,

I’ve tried to deploy my app this morning, but i get the following message

I don’t really understand how to solve it. I try to correct my error and reboot but nothing works.
The following is the library etc :

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import streamlit as st
from sklearn.preprocessing import StandardScaler
import as px
import matplotlib
from lightgbm_with_simple_features import *
import lightgbm
from lightgbm import LGBMClassifier
from sklearn.metrics import confusion_matrix
from PIL import Image
from sklearn.model_selection import train_test_split
import shap
import streamlit.components.v1 as components
import pickle
import plotly.graph_objects as go
import lime
import lime.lime_tabular
st.set_option(‘deprecation.showPyplotGlobalUse’, False)
import altair as alt
import re

and this is some functions i’ve used :

def st_shap(plot, height=None):
shap_html = f"{shap.getjs()}{plot.html()}"
components.html(shap_html, height=height)
def shap_explainer():
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X2)
#fig_summary_shap = shap.summary_plot(shap_values, X2)
return explainer, shap_values #, fig_summary_shap
def lime_explainer():
explainer = lime.lime_tabular.LimeTabularExplainer(X_train.astype(int).values,
return explainer

If you have some hints … Thanks for considering!


Please don’t post code as images, it is quite useless. Please use markdown format instead.
Please post the content of the requirements.txt file or even better, provide a link to your public github repo.

Sorry for this, i’ve corrected my previous message.
I’ve only written the function that i suppose that could be a problem.

For my requirement.txt :

pandas == 1.1.3
numpy == 1.20.2
lightgbm == 3.1.1
flask == 1.1.2
scikit-learn == 0.24.1
matplotlib == 3.3.2
seaborn == 0.11.0
plotly == 4.11.0
shap == 0.37.0
lime ==

To be honest, the git is a part of a training and i don’t know if i can link the repo even if it is public … but I’ll do it if necessary !

I’ve forgotten to precise that the app works perfectly in local.

To deploy to streamlit sharing, the github repo has to be public anyway, so you can also share the link here, that makes debugging much easier…

Indeed … :laughing: The link :

And there are really no other error messages in the log?

Nothing at all excepted the message in image in my first message.
The app run just 2 seconds, display the title and stop.

Okay, that would be an important piece of information.
Then the deployment apparently does not fail.

After displaying the title, i’ve this : ohno

This is my first app, that’s why i’m little bit lost.

you need to put streamlit into the requirements

Indeed, it was no updated. It is the case right now :


I’ve tried to deploy it on Heroku too, so i added the procfile :

web: sh && streamlit run

and :

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

Unfortunately, it is still not working :
On StreamLit Sharing, I’ve this message :

And on Heroku:

I don’t really know how to deal with this error to be honest, i keep looking for a solution … i take all advice !

I would slim down the application significantly until something works.
From there, increase the complexity again.

I’ve followed your advice Franky1. So the problem seems to be the following things : i would like to integrate Lime and Shap graphics but when i run the associated functions, the deployment fail.

I’ve tried these codes :

for Shap :

 def shap_explainer():
     explainer = shap.TreeExplainer(model)
     shap_values = explainer.shap_values(X_train)
     fig_summary_shap = shap.summary_plot(shap_values, X_train)
     return explainer, shap_values #, fig_summary_shap

and in my main :

 st_shap(shap.force_plot(shap_explainer()[0].expected_value[1], shap_explainer()[1][1][client,:], X_train.iloc[client,:]))

for Lime :

 def lime_explainer():
     explainer = lime.lime_tabular.LimeTabularExplainer(X_train.astype(int).values,  
     return explainer
fig = plt.figure(figsize=(20, 20))
exp = lime_explainer().explain_instance(X_train.iloc[client].astype(int).values, prob, num_features=10)
plt.title('Importance locale des features')
html = exp.as_html()
components.html(html, height=500)

for Lime i’ve also tried :

fig = plt.figure(figsize=(20, 20))
 exp = lime_explainer().explain_instance(X_train.iloc[client].astype(int).values, prob, num_features=10)
plt.title('Importance locale des features')

and it does not work, if you have any idea :laughing:

Btw, please post your code in proper markdown format here, otherwise it is not readable:

put your python code here

Sorry for this… it would be better now !

These individual code snippets are too confusing for me, unfortunately I can’t do much with them.

But what strikes me: You can’t call any plot functions directly.

Everything that should be displayed in the browser must be called via some streamlit component.
Anything you try to do past that will go wrong.

PS: Streamlit does not work like a Jupyter Notebook

In fact Franky1, i’ve tried to be concise but maybe too much.

So I’ve just managed to deploy the dashboard ! the solution was to take only a sample of my data …
The initial data had a shape of (300000, 245). With a sample of 5% that works …