-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Python Interactive for use as a debugging console #1278
Comments
@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 ***@***.***> 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 |
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 :)
and interact with it at the |
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. |
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 |
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 |
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 |
@sedghi you should be able to use the first option:
You'd start the debugger using the interactive window. This should be possible now minus the settings (arguments to pass to the script etc). |
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. |
Just created a bounty on Bountysource for this issue, would really love to see this as a feature: |
It seems like there are a lot of different possibilities discussed here, but one of them seems to be: use IPython in the debug console. I would sure love to see this feature as well. I don't want to debug in a Jupyter type interface. I just want to set a breakpoint and when I hit it, I can use IPython to inspect things. Maybe this is already possible but if so the setup is not well documented. As others have said, this is a major limitation of using VS Code for Python, esp. data science type tasks |
How can I keep using the interactive terminal while debugging the current file in the Interactive Window? I have a situation where during a debugging session I would like to interact with the images using matplotlib. Problems:
The way I am dealing with this is logging the images to file (.jpg, .png, etc) in an oldschool OpenCV C++ style. That is not interactive at all, and I always need to convert the images to unsigned chars before saving it to .jpg. Matploblib lets me visualize arrays with any datatype as image using |
You simply type your expressions into the debug console instead of the edit box for the interactive window. Internally the interactive window is listening to the output of a cell running. So we do something like this:
So it won't accept another request (which is what the input box sends). However the debug console window does something different. There's a separate thread in the kernel that the debugger inserts and it evaluates whatever you type on that thread. So it's not blocked. However the output from that eval ends up getting sent back to our code as an output. Here's an example of me printing something from the debug console as I'm debugging a cell: |
Sorry! is the feature suggested by @jbeyer16 available now? |
Actually, I just found out that the feature exist in vs code. see solution from this stackoverflow thread. |
This is not what this question / feature request is about. @jbeyer16 was not asking for any interactive debugger, but for the debugger to run in what the Python extension calls the Python Interactive console. |
After reading through this thread, it sounds like the most feasible and popular solution to this would be
I attempted to run a cell from a separate IW on the same live kernel and that didn't work, so we would likely need to use the separate thread as suggested here
If that wouldn't provide what you're after, please open a separate issue that can be discussed and voted on. |
I'm wondering, would that still work for outputs? Yesterday Don said that running code via the debugger does not run in "inside the kernel", and I don't know exactly what he means by that, but maybe outputs are what would be missing. |
As far as I remember, running evals in the debugger thread still causes the output to go to the currently running cell. You can test this by just evaling something in the debug console while debugging the interactive window. |
Another vote for this feature! |
It has been more than 4 years since this post appeared. Any update on when it is going to be implemented? One thing that (hopefully) is easy to implement is to have a better support for the %pdb magic command of IPython |
I just published package that is my attempt at solving this problem. The idea is to make it easy to save all local and global variables at a specific point during the debug process to disc and then load them again into an interactive window (and even close the interactive window and load them again and again if needed). https://github.com/v4lue4dded/debugsnap/ first install the package into the env you want to debug: pip install debugsnap then start a debugging session using the interactive window environment where you want to debug: (this doesn't have a keyboard shortcut by default, Go a breakpoint in the code where you want to save the snapshot and there open the debug consol:
Now you have all the variables that where present at the breakpoint in an interactive window. PS: follow the links for info on how to make the saving and loading code into VSCode snippets |
@IanMatthewHuff I understand it's a while ago, but do you remember what the outcome was in the triage meeting? |
Sorry to bother you again @IanMatthewHuff, but did you have the chance to check what the outcome was of the last triage meeting? Or are you no longer involved and is it better to contact someone else? |
Ian is not on the project anymore. With the number of upvotes, this is something we would love to implement, it's just hard to find the time. It would be great to see more feedback on @v4lue4dded's solution posted above to know if that is in the right direction. |
@b-a0 I don't know if this will help: After some growing frustration with the interactive mode not being similar enough to Spyder IDE, I decided to make VS Code more similar to it by myself.
mentioned above
I don't want to criticize the interactive mode, but as @amunger themselves said, they do not have time to develop this debugging feature, which for me is essential. I spent most of my time developing in debugging mode and I want the same dynamic that one gets of of IPython. Also, in another point instead of improving the interactive mode, the Python team of VS Code (which not the same as the Jupyter team of VS Code, which developed the Interactive mode) has been dedicating resources to create an integrated REPL that (last time I checked ) does not address many of the issues that the community seems to have with the interactive mode, including the one on this thread... In my opinion, IPython is a phenomenal project, with very good people working on it, and is the best REPL for Python. The vanilla version is not as complete, but is super powerful. |
In spirit this is the functionality, but Perhaps it's a slightly silly/rude description, but I think the best way of showing what I am looking for (I hope it matches what this issue is about) is to download Spyder, write a script, set a breakpoint and start debugging. |
@raphaelchinchilla great to see that you found this creative workaround. Unfortunately I have to share my code with others and it would introduce an unacceptable overhead if I would scatter breakpoint commands everywhere and/or would have to remove those before each commit. |
same .. this is such an unfortunate feature miss. Will utilize the workaround for now but it's certainly not ideal. |
For all that matters, I believe there is a pre-commit hook that will check for that, but I am not sure. If anyone finds please share if possible :). Also, I don't know if I have a configuration problem in my VS Code, but running the debugger makes my code orders of magnitude slower than when I use a breakpoint. |
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:
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!
The text was updated successfully, but these errors were encountered: