Is it possible to run IPython instead of Python command prompt if I hit F5 debug?

Feb 9 at 8:20 PM
Hi,

I really like PTVS since i allows me to write Python code next to C#. I have installed zipline - a trading library which uses matplotlib graphics -. Those graphs are not visible in the Python command window. For that reason I found out that I can copy paste my code to the intermediate window. However, is there not a way to just press F5 which then starts the iPython and then runs the graphs + allow me debugging step-by-step with break points.

I tried to add a new environment..but did not succeed. Is this possible?

J.
Coordinator
Feb 9 at 10:11 PM
How are you showing the graph in your script once plotted? matplotlib.pyplot.show() should show the graph in its own window when running normally.

As a side note, you can, in fact, debug the code that you're running in the Interactive window, with breakpoints etc. The $attach directive will attach VS as a debugger for the Python process that backs the Interactive. You can also run a script in the Interactive by using the $load command in it.
Feb 11 at 8:21 PM
pminaev wrote:
How are you showing the graph in your script once plotted? matplotlib.pyplot.show() should show the graph in its own window when running normally.
Yes, this works. Thank you. Basically, I can debug now. And plots are shown.

pminaev wrote:
You can also run a script in the Interactive by using the $load command in it.
This works also.

pminaev wrote:
As a side note, you can, in fact, debug the code that you're running in the Interactive window, with breakpoints etc. The $attach directive will attach VS as a debugger for the Python process that backs the Interactive.
I cannot get this to work. I set a breakpoint in my code file. I enter $attach. Then I do CTRL-A-E-E so that code moves to Interactive. No breakpoint hit, but maybe this is because both are not connected so my breakpoint should be somewhere else. I need to try out a bit more.

Thank you for the prompt reply.
Coordinator
Feb 11 at 8:26 PM
You can't have breakpoints in the code that is directly entered in the interactive - your original breakpoint won't be hit when you copy/paste the code (or use the command, which basically does the same thing), because the breakpoint is bound to a specific line in a specific file - and the code running in the Interactive does not belong to any file.

However, if the Interactive imports some module from disk and runs some code in that module (e.g. calls a function in it), then a breakpoint in the corresponding file will be hit while running under $attach.
Feb 12 at 11:44 AM
pminaev wrote:
You can't have breakpoints in the code that is directly entered in the interactive - your original breakpoint won't be hit when you copy/paste the code (or use the command, which basically does the same thing), because the breakpoint is bound to a specific line in a specific file - and the code running in the Interactive does not belong to any file.

However, if the Interactive imports some module from disk and runs some code in that module (e.g. calls a function in it), then a breakpoint in the corresponding file will be hit while running under $attach.
So what should be the working flow in case Im changing a function in the editor and want to debug it from the interactive? I probably need to reload the module in some way, how should one do that?
Coordinator
Feb 12 at 3:43 PM
You can use the standard Python reload function to reload a module (in Python 3, it was moved to the imp module).