Vs code debug

How to debug a streamlit.io python app using VS Code?

Thank you!

1 Like

Hi @Nelson_Silva

The poor mans version is to just set a breakpoint() in the code.

You can see an example below where i’ve set the ‘breakpoint()’ and can inspect the selection in the terminal below.

I don’t know how to integrate it with VS Code though. I never use that because I find it slow :slight_smile:

Thank you for the previous answer.

After some reading, here is the description on how to debug Streamlit apps using VS CODE:

In your streamlit/Python code add:

import ptvsd

-> 5678 is the default attach port in the VS Code debug configurations

print(“Waiting for debugger attach”)

ptvsd.enable_attach(address=(‘localhost’, 5678), redirect_output=True)


-> use: breakpoint(), to set a manual breakpoint using code, or just enable a breakpoint using the mouse on the code line (as usual)

-> Next run you Streamlit as usual: streamlit run test.py
-> Next, you just need to press the play button on VS CODE, and then select the Remote Attach: debug PTVSD option…


1 Like

Hi @Nelson_Silva

Your description got me started writing some suggestions on how to use VS Code for developing Streamlit applications. See https://awesome-streamlit.readthedocs.io/en/latest/vscode.html


1 Like