Streamlit python app deployed successfuly on heroku but Error Python may not be configured for tkinter

My streamlit app run well localy (windows anaconda python 9.3.13 and is successfully deployed on heroku but failed to run online because of this error : File “/app/.heroku/python/lib/python3.9/tkinter/init.py”, line 37, in import _tkinter # If this fails your Python may not be configured for Tk

I read solution here and on stackoverflow and test them especially change python version, reinstall tkinter via anaconda, but il am on windows without wsl I don’t know how to install or reinstall tkinter with apt-get or brew …

On streamlit.share I have got the same issue and solve it with a packages.txt file with just this line libtk8.6, solution I had found on this forum… it works fine my app run on share.streamlit.io but I can share it because this service need to subscribe an account and it’s not possible for the people who I want to share the app…

On heroku, I try to add libtk8.6 in the runtime.txt file needed by heroku but it doesn’t work …

Thanks to help me … if somebody had the same issue.

In don’k know how, or even if, you can import tkinter in Heroku, but more often than not you should be fine just not importing it. What would you want to use tkinter when running in a headless server?

1 Like

Thanks @Goyo for your reply. I don’t want to use tkinter, i have understood that import tkinter is adding by streamlit when using matplotlib or another datavisualisation library… As I have spent more time attempting to deploy the app than creating it, I have tried to run without this import of tkinter but my app doesn’t run anymore … the main purpose of this app is to visualize data so I need plotly seaborn or matplotlib…
Thanks again, I’ll had the same remark as yours on stackoverflow…

I wonder what makes you believe that. I am pretty sure streamlit does not need tkinter for anything, including matplotlib and plotly visualizations. It just makes no sense.

Unfortunately, “my app doesn’t run anymore” is not a very useful description of whatever is happening. Have a look at the guidelines for posting and help us to help you.

Thanks again @Goyo. I have disable lines of code which refer to tkinter commenting them out, and it works. My webapp is successfully deployed on heroku without error. Thanks again !