Closed xgnata closed 2 years ago
Let's keep the discussion at the issue in debugpy
which already has more info...
We figured out in this discussion that sys.stdout is set to None when we use pythonw.exe. One can use python.exe to have a propre sys.stdout. Nevertheless, it would be good to add a try/catch or a test in matplotlibtools.py in order not to confuse other users.
The debugger crashed in vcode in matplotlibtools.py as soon as matplotlib is imported. pydevd (2.8.0) Python extension for Visual Studio Code v2022.5.11111003 Visual Studio Code 1.66.2
See also See also https://github.com/microsoft/debugpy/issues/891 :
Traceback (most recent call last): File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_frame.py", line 948, in trace_dispatch self.do_wait_suspend(thread, frame, event, arg) File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_frame.py", line 164, in do_wait_suspend self._args[0].do_wait_suspend(*args, **kwargs) File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd\pydevd.py", line 2023, in do_wait_suspend keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker) File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd\pydevd.py", line 2046, in _do_wait_suspend self._activate_gui_if_needed() File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd\pydevd.py", line 1571, in _activate_gui_if_needed activate_function() File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd\pydevd.py", line 1555, in
self.mpl_modules_for_patching = {"matplotlib": lambda: activate_matplotlib(do_enable_gui),
File "c:\Users\gnata.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy_vendored\pydevd\pydev_ipython\matplotlibtools.py", line 98, in activate_matplotlib
sys.stdout.write("Backend %s is interactive backend. Turning interactive mode on.\n" % backend)
AttributeError: 'NoneType' object has no attribute 'write'
Commenting out this line sys.stdout.write("Backend %s is interactive backend. Turning interactive mode on.\n" % backend) is a good enough workaround but it is probably not the right way to fix it.