-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Own code not recognised when virtualenv
interpreter selected.
#19871
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
Comments
I had a suspicion it might be Pylance after finding out that it assigns the python PATH on start and doesn't reassign it, but after restarting Pylance and ensuring a known good version of Python was being run, the issue persisted. |
After a full restart, the issue still persists. I am distraught at the loss of my breakpoints. The sheer refusal to break, not out of resilience, but of sloth. |
Deleted my |
I return to you very confused. I figured that if the issue was persisting after a full restart, the culprit must persist too. Took one look at |
I've gotten just a little bit further down the debugging track. After deleting the |
@EzraEn1 The Output > Python logs capture the selected interpreter and the command that is used to launch the debugger. If you can share that it would likely help digging into the issue. |
set |
I can confirm that @luis-guilherme's indicated behaviour is true, setting |
@karthiknadig , here's your requested
|
And the equivalent from my known-good:
|
It appears that there are issues with breaking breakpoints when debugging using a virtualenv version of pyenv. Even when outside of the venv on the CLI, if the Python interpreter selected is the venv version, breakpoints will not break. This may be related to the fact that the Python extension seems to discover available Python versions only on runtime, and does not recognise other versions available to pyenv, or recognise when there are new versions available to the extension. As a result, the extension doesn't recognise when there is a context change (the venv in this case) and doesn't change interpreters to accommodate. |
I can force the issue by manually changing the Interpreter to the one inside the |
Found an interesting thing, the hashes for both interpreter executables are different, and have different sizes! They both purport to be of the same release tag: But the hashes and sizes of each are different: virtualenv interpreter |
Perhaps this is relevant to what @luis-guilherme mentioned? Perhaps our own code is mistakenly marked as "notOurCode" exclusively when running with a |
virtualenv
interpreter not selected.
virtualenv
interpreter not selected.virtualenv
interpreter selected.
I will also need details on how your project is organized. in relation to the virtual env. Here is how 'user code' and
Depending on how you have laid out the code for your project, and how it appears in relation to the where the virutalenv sits, it could treat it as library code. First run the following, two commands:
As far as I can tell from the above description, your 'src' is under one of the site packages paths. |
@karthiknadig Output of Seems to be considering the project root ( |
Thats is correct, the src should be outside of it. Typically this is the project structure that is expected:
|
Well that clears a lot up! I've gone ahead and recreated my venv in a separate project directory, and everything's testing properly now, even with |
We can consider this closed! Thank you for providing the details that made it easier to diagnose. |
Type: Bug
Behaviour
Expected vs. Actual
Expected:

Enabled breakpoints remain enabled, and are hit.
vs.
Breakpoints are disabled
Steps to reproduce:
virtualenv
andactivate
it.venv
Python interpreter.Problem is independent of Python version (so it's not a duplicate of #15890, #15861 or this specific issue with debugpy.) I have changed versions multiple times within the venv and out and noticed that only within the venv does this problem manifest. Also tested with known good version Python 3.9.4, same result within both venv and out.
Also not whatever this is. The commenter appears to have misunderstood the issue, but if it's any help, the status bar does change state.
This issue may indeed be a duplicate of #12593, but after testing python3.9.4, I noticed the issue occur even outside of the venv.
The strangest thing is that this seems to crop up at random, I had previously been working with the same exact environment and venv with no issue.EDIT: The issue occurs because the debugger doesn't recognise your code as your code when you're using the
virtualenv
interpreter and turns off your breakpoints because "Hey, you said you didn't want to see anything else other than your own code, right? Here's absolutely nothing because none of this code is yours." Enable'justOwnCode': false
in yourlaunch.json
for a workaround if you don't want to use other intepreter executables.Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2022.14.0
VS Code version: Code 1.71.2 (74b1f979648cc44d385a2286793c226e611f59e7, 2022-09-14T21:03:37.738Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: