I'm writing python in visual studio 2015. I want to ask how to step into a library if I'm using a function that is defined in the library.
For example, I wrote the following code,
import numpy as np
from sklearn import linear_model, datasets
np.random.seed(0)
regdata = datasets.make_regression(100, 1, noise = 20.0)
And I want to step into the makeregression() function at 4th line (this function is defined in samples_generator.py, scikit-learn package) to see what is happening inside of the function. When I press F11(shortcut for step into) in visual studio, instead of moving into samples_generator.py, the arrow just moves to next line of my code.
Is there a way to let me step into a function which is defined in a library? Appreciate your help.
If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.
Starting Python Debugger To start debugging within the program just insert import pdb, pdb. set_trace() commands. Run your script normally and execution will stop where we have introduced a breakpoint. So basically we are hard coding a breakpoint on a line below where we call set_trace().
To continue running the program until the next breakpoint is reached, use Continue (F5). Because you have a breakpoint in the for loop, you break on the next iteration. Stepping through hundreds of iterations of a loop can be tedious, so Visual Studio lets you add a condition to a breakpoint.
To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.
Did you try to use the option "Enable debugging of the Python standard library" in Python Tools:
To get here, open Tools->Options->Python Tools->Debugging in Visual Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With