avatarAlessandro Galetto

Summary

This article provides instructions on how to debug Streamlit scripts using PyCharm.

Abstract

Streamlit is a Python package that allows developers to create dashboards without extensive front-end development knowledge. The author of this article, a backend developer, found Streamlit useful for organizing and visualizing data. To debug Streamlit scripts in PyCharm, the author suggests adding a Run/Debug configuration, which enables setting breakpoints and debugging as usual in PyCharm. This solution also works with Visual Studio Code.

Bullet points

  • Streamlit is a Python package for creating dashboards without deep front-end development knowledge.
  • The author, a backend developer, finds Streamlit useful for organizing and visualizing data.
  • Streamlit runs on a local dedicated web server for local development.
  • To debug Streamlit scripts in PyCharm, add a Run/Debug configuration.
  • This solution also works with Visual Studio Code.
  • After adding the configuration, set breakpoints and debug as usual in PyCharm.

Debugging Streamlit with PyCharm

Photo by path digital on Unsplash

Streamlit is a Python package that allows you to build beautiful dashboards from Python without the need for a deep knowledge of front-end development. This is my case. I have never been interested that much in front-end development. I was, and I am a backend developer type.

Since I am playing with different data coming from our systems, I found Streamlit incredibly useful for organizing and visualizing the data I collect. You can run your dashboard locally and deploy it in the cloud when you need to share it with others in your organization.

I love PyCharm, which I use for my Python development.

As for every application, you need some debugging to ensure you are doing the right thing.

When you develop locally, you run a local Streamlit, dedicated web server. How can you debug my script in PyCharm?

I spent some time thinking about it and found a solution that may be helpful to other people out there. This will work in Visual Studio Code as well, but I didn’t try it since I don’t love Visual Studio Code so much.

You can add a Run/Debug configuration to PyCharm like the one you see below:

PyCharm — Add Run/Debug Configuration

PyCharm — Add Run/Debug Configuration Screen

Now you can set your breakpoints in the script and debug it as you usually do in PyCharm.

Streamlit
Pycharm
Python
Debugging
Recommended from ReadMedium