ISSUE About the Deploying on Streamlit Claud

Hello i have problem for the deployment of my app.

This is the code:
from asyncore import read
from cgitb import reset, text
from email.policy import default
from optparse import Values
from re import template
from tkinter.tix import COLUMN
from turtle import title
from unicodedata import name
from wsgiref import headers
import pandas as pd
import streamlit as st
import plotly.express as px
from PIL import Image

st.set_page_config(page_title=‘NF NOTAI’)
st.header(‘Data Analysis 2022’)
st.subheader(‘was the analysis helpful?’)

— LOAD DATA FRAME

excel_file = ‘data.xlsx’
sheet_name = ‘data’
sheet_name1 = ‘dati’

df=pd.read_excel(excel_file, sheet_name=sheet_name, usecols=‘A:E’, header=6)
df_log=pd.read_excel(excel_file, sheet_name=sheet_name1, usecols=‘C:E’, header=5)

st.dataframe(df)
st.dataframe(df_log)

pie_chart = px.pie(df_log, title=‘Macroarea’, values=‘Interesse Regionale’, names=‘Macro Area Servizio’)

st.plotly_chart(pie_chart)

— streamlit selection

department = df[‘Macro Area Servizio’].unique().tolist()
interest = df[‘Interesse Regionale’].unique().tolist()

department_selection = st.multiselect(‘Macro Area Servizio:’, department, default=department)

—FILTER DATAFRAM BASED ON SELECTION

mask = (df[‘Macro Area Servizio’].isin(department_selection))
number_of_result = df[mask].shape[0]
st.markdown(f’Available Results: {number_of_result}')

df_grouped = df[mask].groupby(by = [‘Macro Area Servizio’]).sum()[[‘Interesse Regionale’]]
df_grouped = df_grouped.rename(columns={‘Macro Area Servizio’:‘Interesse Regionale’})
df_grouped = df_grouped.reset_index()

bar_chart = px.bar(df_grouped, x = ‘Macro Area Servizio’, y = ‘Interesse Regionale’,
text = ‘Interesse Regionale’, color_discrete_sequence = [‘#F63366’]*len(df_grouped), template= ‘plotly_white’)

st.plotly_chart(bar_chart)

this is the requirements:
pandas<1.2
xlrd<2.0
Pillow==9.2.0
plotly==5.10.0
streamlit==1.13.0
tk==0.1.0

This is the error message:

Hi @giovanni231995,

Can you share the full error message? If you click on the console on the right hand side, you should be able to copy and paste a longer error message.

Caroline

1 Like

File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 562, in _run_script
exec(code, module.dict)File “/app/testapp.py/app.py”, line 6, in
from tkinter.tix import COLUMNFile “/usr/local/lib/python3.9/tkinter/init.py”, line 37, in
import _tkinter # If this fails your Python may not be configured for Tk

Are you actually using tkinter inside of your streamlit app? I wouldn’t expect that to necessarily work well, but if you do need it, you might need to add a packages.txt as suggested in this post.

Hello

Thank you but how can i add package.txt?

It’s just another file, just like requirements.txt, just called packages.txt

See more in the docs – App dependencies - Streamlit Docs

hello,

thank you so much for your explanation.
I tried to create packages.txt but now i had front other issue:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 562, in _run_script
    exec(code, module.__dict__)File "/app/testapp.py/app.py", line 28, in <module>
    df=pd.read_excel(excel_file, sheet_name=sheet_name, usecols='A:E', header=6)File "/home/appuser/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)File "/home/appuser/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 317, in wrapper
    return func(*args, **kwargs)File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 483, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 1672, in __init__
    self._reader = self._engines[engine](self._io, storage_options=storage_options)File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/_openpyxl.py", line 548, in __init__
    import_optional_dependency("openpyxl")File "/home/appuser/venv/lib/python3.9/site-packages/pandas/compat/_optional.py", line 145, in import_optional_dependency
    raise ImportError(msg)