-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Debugging a script run from within a virtual environment's directory does not work #2520
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
@primes2h Thanks for the report. Can you run your python script from the command line? From the interactive shell prompt within VSCode? |
@d3r3kk I'm sorry, I can't right now (until Monday). :-( Can someone else do it in the meantime please? |
@d3r3kk I can run my python script from the command line, and also from the shell prompt within VSCode. When I use |
@d3r3kk The debugger will stop at the breakpoint in the last version of ms-python. ( version 2018.7.1 ) However, once I import some packages, similar issues occurs: |
I think I understand the trouble now, and I can indeed reproduce undesirable behaviour, although slightly different in how it presents itself on my machine. The file that @Reyshawn is debugging has been placed inside the virtual environment directory itself. I believe this is unexpected but I'm not sure if it is invalid or not, @brettcannon? For now, please do this to set up your environment and let us know if it starts working for you or not:
a = 1
b = 2 # put breakpoint here
print(a+b)
Does this workaround get you running? |
I can't think of any reason why this scenario shouldn't be supported, but it isn't typical so I'm not sure when we will prioritize fixing it. |
I think I'm hitting the same problem, only that I'm running a script from the root directory (interpreter is set to the venv) and have a breakpoint set in a venv'ed library. The debugger does not delve into the venv'ed library. |
I faced the same issue. Any updates? |
To debug into third-party code (which is anything inside a venv), set |
Environment data
Actual behavior
When I set a breakpoint in the venv environment, and click the debug, the
runpy.py
file popped up and the program stopped at line 85.Expected behavior
The program should have stopped at the line where I set the breakpoint.
Steps to reproduce:
python3 -m venv test
"python.pythonPath": "${workspaceFolder}/bin/python3"
set a breakpoint at line 2, click the debug, a
runpy.py
file popped up and the program stops at line 85:exec(code, run_globals)
, as the following image shows.Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Nothing
Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
)The following statements are executed in the integrated terminal :
launch.json:
The text was updated successfully, but these errors were encountered: