Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a 3rd-party Python package in VS Code

How to enter into imported package while debugging in VS code

As an example:

import os
import mdfreader
k123 = mdfreader.mdf("Test.mf4")

How to enter into the mdf function in the imported package

like image 554
Heroheralal Avatar asked Nov 07 '18 15:11

Heroheralal


People also ask

How do I debug a Python package in VSCode?

You can also start the debugger by clicking on the down-arrow next to the run button on the editor, and selecting Debug Python File in Terminal. The debugger will stop at the first line of the file breakpoint. The current line is indicated with a yellow arrow in the left margin.

How can we debug a Python program via code?

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().

How to debug Python code in VS Code using the debugger?

By default, the debugger uses the same interpreter selected for your workspace, just like other features of Python extension for VS Code. To use a different interpreter for debugging specifically, set the value for python in launch.json for the applicable debugger configuration.

How do I debug a Python program?

The simplest way to begin debugging a Python file is to use the Run view and click the Run and Debug button. When no configuration has been previously set, you will be presented with a list of debugging options. Select the appropriate option to quickly begin debugging your code.

How to debug 3rd party libraries with source code in Visual Studio?

You’ll be able to step into (F11) the 3rd party library and debug freely with source code and all other VS features available: Like with all other methods in this article, when using this, you need to disable the “Enable Just My Code” option and enable the “Suppress JIT optimization on module load” option.

When to debug 3rd party code?

There are many cases when there’s an exception in the 3rd-party code that you want to debug. Here are some examples: When something strange is going on and you can’t understand why. For example, a request to your server returns a 500 error code for no apparent reason.


1 Answers

In your launch.json add the "justMyCode": false setting. That will allow you to step into third-party code.

like image 65
Brett Cannon Avatar answered Oct 09 '22 11:10

Brett Cannon