vscode-jupyter
vscode-jupyter copied to clipboard
Enable Python Interactive for use as a debugging console
I think this is related to / mentioned deep in the comments here, but I'm not convinced they're quite duplicates.
I think it'd be tremendously useful to be able to also select Python Interactive as your debug terminal, essentially launching a Python Interactive window at a breakpoint with the state of your program loaded into it, giving you access to your variables. That way plotting functions and visualizations could be made use of pretty easily as a way of debugging. This varies slightly from the current "Debug Current File in Python Interactive window", which would run your entire script in Python Interactive, in that you are still able to configure the debugger launch.json. For my specific use case it would allow passing in command line args to the script, while still being able to debug in Python Interactive.
At a high level, I can see two ways of it happening:
- Use only Python Interactive and allow it to continue execution of the code as the full debug tool.
- Use the main debug terminal for the debugging flow, but at a breakpoint launch the Python Interactive window that opens preloaded with the current program state. At that point, the Python Interactive window is essentially detached from debugger, but at least has the data from the program at that time, allowing for more native exploring of the variables. Once the user continues debugging, the current Python Interactive window is either updated or a new one is launched at the next breakpoint.
My current work around is just to write a data frame to a .csv in the current debugger, then load it into Python Interactive - which works well enough, but I think it'd be really helpful if they were somehow integrated!
Thank you for making this product so awesome to use!
@jbeyer16. I like this suggestion, right now there is a bit of an odd bifurcation between the debugging and interactive debugging workflows. We'll consider it in the next triage meeting.
awesome! looking forward to seeing how it develops. thanks!
Great suggestion @jbeyer16. Thanks for considering @IanMatthewHuff - the described functionality would be a huge improvement for my workflow.
@gramster I understand debugging Python inside Jupyter is not easy. Did you check out how the problem was solved in 2018 by PixieDebugger? (https://medium.com/codait/the-visual-python-debugger-for-jupyter-notebooks-youve-always-wanted-761713babc62)
We’re not trying to implement a debugger that runs entirely in Jupyter cells; for us we have to integrate the debugger into the overall Visual Studio Code debug experience. It’s a different problem.
On Sun, Nov 3, 2019 at 4:57 AM Adam Ryczkowski [email protected] wrote:
@gramster https://github.com/gramster I understand debugging Python inside Jupyter is not easy. Did you check out how the problem was solved in 2018 by PixieDebugger? ( https://medium.com/codait/the-visual-python-debugger-for-jupyter-notebooks-youve-always-wanted-761713babc62 )
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-python/issues/6972?email_source=notifications&email_token=AAVCPCBGAOJT4LOQQ5PZ6XLQR3DCHA5CNFSM4ILYADY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5R6QQ#issuecomment-549134146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVCPCFNKSK6XSNSHGB7HULQR3DCHANCNFSM4ILYADYQ .
Yes this would be a great feature, just like in Spyder the debug console is limited and not easy to use. Interactive python is much better
This is actually extremely useful for data-science oriented work. PyCharm somehow does this seamlessly, when debugging a regular Python project, the "Debug console" is actually an IPython one. That means, for instance, that it can be used for interactive matplotlib plotting even when the project is not executed in jupyter.
I'm interested to understand how something like this would be implemented to see if I can find some "ugly" temporary workaround. So maybe I can start some sort of listener server in my own code , then when stopped on a breakpoint I coudl launch IPython from the terminal and somehow "attach" it to my current session
@syagev don't know if this is what you want but it's kind of workaround and it's definitely ugly :)
you can launch an embedded IPython REPL right from the DEBUG CONSOLE tab
import IPython
IPython.embed()
and interact with it at the TERMINAL tab.
Has there been any update on this ? I love VScode but this is the sole reason I don't use it over my current IDE
I need this feature man.
I need this feature man.
same - honestly would love to use VSCode as my main IDE but there's no way I can effectively debug without an interactive debugger
I didn't know this wasn't possible and just lost my morning trying different configuration options to make it so. This feature is a must have for me. I find the inconsistency between debug and interactive consoles annoying
Awesome! I am looking forward to a new interactive debug like WingIDE's. Thanks
@NetanelRabinowitz This is such a useful hint. It would be great if this could be made into an automatic process somehow so that everything a particular debug config was run the terminal would have an interactive IPython session.
I think the original problem could possibly have been solved by allowing the user to specify the interactive debug settings in the launch.json.
This is absolutely an necessary feature for data science and machine learning projects. can we have it?
Which 'this' are you referring to? Launch with interactive as an option in the launch.json is likely possible, but connect to a python process with the interactive console is not.
@rchiodo Sorry if i was not clear, I was referring to a PyCharm-like debug console which is IPython. I tried all the above answers to have a simple matplotlib plot to show up while debugging, and it didn't work.
The ability to drop into an IPython debug console anywhere is a very powerful tool, and is a real USP of PyCharm.
I would also like to chime in here and say that this is really a big blocker for my department's adoption of VS Code.
Looking for this feature as well
@syagev don't know if this is what you want but it's kind of workaround and it's definitely ugly :) you can launch an embedded IPython REPL right from the
DEBUG CONSOLEtabimport IPython IPython.embed()and interact with it at the
TERMINALtab.
Meanwhile - is there any way to automate this nice workaround?
Edit: I missed @bashtage's similar comment.
is there any update here?
This item is kinda ambiguous.
The original request was to support launch.json settings for the interactive window. That might happen. We don't have a definite plan for it though.
The other request was to allow the user to switch to an IPython terminal in the middle of debugging. That will likely never happen. Transferring kernel state (especially from a non kernel runtime) is non trivial and not something we're likely to pursue.
We might allow the user to start the debugger with IPython as a terminal though. Basically automate the workaround as described by @NetanelRabinowitz up above.
The status of this issue is waiting for @jmew or @claudiaregio to split it into those 3 parts.
@rchiodo As I described in the previous comments, a very handy tool that PyCharm has is that it allows to plot in the middle of debugging which is super useful for different areas of image analysis especially in medical imaging. The IPython as a terminal with a workaround above does not allow for plotting of any kind.
@sedghi you should be able to use the first option:
- support launch.json settings for the interactive window.
You'd start the debugger using the interactive window. This should be possible now minus the settings (arguments to pass to the script etc).
We might allow the user to start the debugger with IPython as a terminal though. Basically automate the workaround as described by @NetanelRabinowitz up above.
I think this is the closest to what PyCharm does. If you have IPython installed, when you drop into the console, you get an IPython session. There is no available to open as a standard Python session and then transform this to an IPython session.
This item is kinda ambiguous.
I am entirely on board with moving forward with suggestion 1 and scratching suggestion 2. They were just ideas I had about how it could be implemented. The main end goal was just being able to use some sort of iPython-like console to debug - (and as others have suggested) mostly to allow for plotting capability within a debug breakpoint.
I'd like to share my debugging workflow, as it is slightly different from OP's request.
It sometimes occurs to me that some functions misbehave and raise exceptions with a specific set of inputs which are generated in Python Interactive windows. It usually takes time to generate the inputs and I would love to have debugging tools at hand keeping the current kernel state. This would involve running a debugger from within Python Interactive, instead of exiting the Python Interactive window and running the debugger.
I realize this issue is about the opposite of what is discussed here: i.e. having a debugger within the Python Interactive window rather than a Python Interactive window within the debugger. Is this something which could be integrated with the solutions proposed here, or is it better to discuss in a new issue? I think this feature would really help me in switching to vscode. Thanks!
@pepicello can you use the existing debug cell? We already have a way to start the debugger while using the interactive window.