I'm trying to debug my python code with VS Code. Below is launch.json
file.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"python": "/home/usr_name/anaconda3/envs/ENV_NAME/bin/python",
}
]
}
It works fine until it finds break point. As soon as it reaches breakpoint, it stops debugging with below message (last few lines).
Backend TkAgg is interactive backend. Turning interactive mode on.
Traceback (most recent call last):
File "/home/usr_name/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py", line 988, in trace_dispatch
self.do_wait_suspend(thread, frame, event, arg)
File "/home/usr_name/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py", line 165, in do_wait_suspend
self._args[0].do_wait_suspend(*args, **kwargs)
File "/home/usr_name/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 2070, in do_wait_suspend
keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker)
File "/home/usr_name/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 2093, in _do_wait_suspend
self._activate_gui_if_needed()
File "/home/usr_name/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 1592, in _activate_gui_if_needed
activate_function()
File "/home/usr_name/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 138, in activate_pylab
pylab.show._needmain = False
AttributeError: module 'pylab' has no attribute 'show'
But in my conda environment, pylab.show
works totally fine.
I already set Interpreter to conda env but that seems not directing VS code to use it in debug. Somehow it's stick with /home/usr_name/.vscode/extensions/ms-python
. How to make it debug with python conda environment?
Edit: I'm not using matplotlib or pylab in my code. It works okay even with debugging. The problem occurs only when it hits breakpoint.