PyCharm debugging instructions does not work in Windows environment

Greetings,

This is a follow up to this post:

https://discuss.streamlit.io/t/version-1-5-0/21455/11

The screenshot in the post is taken from a MAC environment.

In windows environment, I am not able to find the streamlit python script. I try the following:

C:\Projects.Personal\exp01>where streamlit
C:\Users\almoeen\Anaconda3\envs\env01\Scripts\streamlit.cmd
C:\Users\almoeen\Anaconda3\envs\env01\Scripts\streamlit.exe

When I try to debug with this configuration:

I get this message in PyCharm:

2022-04-14 21:22:10.404
Warning: to view this Streamlit app on a browser, run it with the following
command:

streamlit run sl01.py [ARGUMENTS]

Process finished with exit code 0

How can I debug my streamlit pages in windows environment and PyCHarm?

Thank you,

I tried to tweak streamlit for a while, but debugging is definitely a challenge.

I learned that if the code sophistication is at a level that I might need to debug it, then it is better to consider Dash(https://dash.plotly.com/). The coding is a little more involved, but it totally worth effort since Dash provides a significantly more power and control over the code.

Hi @python_trader -

I’m not a Windows user, so take this with a grain of salt…

It would appear that PyCharm on Windows doesn’t like the method on the forum you link to…as far as I can tell, you can’t actually link to the Streamlit .exe file from the Script path: menu. It wants you to link to a Python script.

Instead, under interpreter options:, if you -m streamlit run, that will effectively expand to python -m streamlit run file.py, and this works for me under the RUN dialog.

But for debug, that configuration doesn’t work for me. It appears that PyCharm dumps a bunch of arguments onto the command line, which are intended for the python executable, but because we put -m streamlit run in the interpreter options section, it gets messed up.

If I can figure out how to disable all of the additional options such as --multiprocessing that PyCharm dumps onto the command line, then it might work. Until then, not sure what to suggest here.

Best,
Randy

It turns out that the StackOverflow post that is linked does actually provide the answer, albeit indirectly.

If you take my suggestion above and make it -m streamlit run --, on my Windows PyCharm is has now started with Connected to pydev debugger (build 221.5080.212)

So give that a shot and see if it does what you want. Separately, I’m going to play with this when I have some free time to understand it better, and once I’m convinced we’ve got a legitimate solution we’ll add it to the docs.

Relevent link: (after line 'EDIT: adding @sismo ‘s comment’):

Best,
Randy

Hi @randyzwitch ,

Thank you for reply.

I’ve tried the Stackoverflow post before I post my question here. Debugging Streamlit in overall is a challenge, but it is even more challenging in Windows platform.

To my understanding Stremlit debugging challenge is due to a fundamental engineering design decision. To elaborate, consider how we run a Dash application:

# this is how we run a dash dashboard application
app.run_server(debug=True)

That mans we can invoke a Dash dashboard within the running Python process and it flows well in any IDE or debugging environment.

However, Streamlit runs dashboards quite differently. We pass a Steamlit layout python file to Streamlit using a python -m . Among so many great things I can tell about Steamlit, I am confused why it doesn’t provide a way to invoke dashboards in a python script like Dash does.

PyTest addresses this matter elegantly. We have many options to invoke Pytest (long topic ) . For debugging PyTest offers this option: How to invoke pytest — pytest documentation

I wish Streamlit provided the option to invoke a dashboard from code and follow the invoking from script pattern that PyTest provides so we can easily debug. I tried, but couldn’t find it.

Kind Regards,