32

I am trying to set a breakpoint in an external Python module in VS code.

I have tried editing the source file and inserting import pdb; pdb.set_trace() where I want the breakpoint.

This enters the pdb command line debugger rather than the debugger in the VS Code GUI.

How do I set a breakpoint in an imported Python module so that I enter the VS Code debugger?

3 Answers 3

38

Marvin's suggestion appears to be sufficient:

add a launch configuration "justMyCode":false . See code.visualstudio.com/docs/python/debugging#_justmycode

Sign up to request clarification or add additional context in comments.

Comments

10

Besides adding "justMyCode":false as mentioned in other answers, there's another minor detail that took me a while to realize. You have to use the "Run" button at the top left:

enter image description here

And NOT the "Run Debug Python File" button at the top right:

enter image description here

Hope that helps saving time of others.

1 Comment

Worked for me! Thanks! (why would the behavior of these 2 buttons be different..)
4

You need to import the folder containing the source code of the imported module into the project, using file -> add folder to workspace. In my case this was /Users/robinl/anaconda3/lib/python3.6/site-packages/great_expectations/

Within VS code, you can then navigate to the file you want to debug and set a breakpoint by clicking to the left of the code as normal.

4 Comments

Also, you may need to add a launch configuration "justMyCode":false . See code.visualstudio.com/docs/python/debugging#_justmycode
Answer given by @Marvin appears to me to be the only necessary step (just tried and it worked)
In VS code version 1.51.0 Marvin's answer is enuf, no need to import the folder! @sivano you should post that as an answer here, the current accepted answer is overkill.
This was the only solution that worked for me! Setting "justMyCode": false was not enough in my case. Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.