[Python] How to debug Python functions in Rstudio?

Discussão em 'Python' iniciado por Stack, Março 13, 2025.

  1. Stack

    Stack Membro Participativo

    I have Python chunks in an Rmd file in Rstudio that I would like to debug.

    I am using ipdb but when it gets to the breakpoint in the function it doesn't open a separate terminal as I was expecting from the ipdb examples online; instead the console prompt just switches to ipdb.

    I can interogate variable values and step thru the code but it is very difficult to work out which line I am on (in the examples online about ipdb when the code opens in a seperate window the current line is indicated by an arrow which updates as you step through the code).

    ```{python}
    import ipdb

    def test(x):
    ipdb.set_trace() #ipdb breakpoint
    y=x*3
    z=y+4
    return z

    test(3)
    ```


    Any suggestions for how to get ipdb to work properly within Rstudio or a Python debugger that is compatible with Rstudio would be great.

    Continue reading...

Compartilhe esta Página