Can't run Debugger - 'Connection to Python debugger failed; Socket closed'

Answered

I've been trying to get the debugger to work on a remote work station but I keep having this error pop up when trying to debug a code/script. Interestingly enough, when I run my scripts normally, I my codes execute without issue, but I really need the debugging tool when creating other scripts. I have tried creating a brand new projects but when I run the debugger again, I have this error pop up.

/mnt/home/jpsc230/anaconda3/envs/rcrest19/bin/python /mnt/home/jpsc230/pycharm-community-2020.1/plugins/python-ce/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 45959 --file /hd2/work/jon/py/pythonProject/rcrest19/test_debugging_rcrest19.py
Traceback (most recent call last):
File "/mnt/home/jpsc230/pycharm-community-2020.1/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py", line 55, in <module>
from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch, global_cache_skips, global_cache_frame_skips, fix_top_level_trace_and_get_trace_func
File "/mnt/home/jpsc230/pycharm-community-2020.1/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 48, in <module>
raise exc
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/home/jpsc230/pycharm-community-2020.1/plugins/python-ce/helpers/pydev/pydevd.py", line 49, in <module>
from _pydevd_bundle.pydevd_trace_dispatch import (
File "/mnt/home/jpsc230/pycharm-community-2020.1/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py", line 63, in <module>
delete_old_compiled_extensions()
File "/mnt/home/jpsc230/pycharm-community-2020.1/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py", line 19, in delete_old_compiled_extensions
cython_extensions_dir = os.path.dirname(os.path.dirname(_pydevd_bundle_ext.__file__))
File "/mnt/home/jpsc230/anaconda3/envs/rcrest19/lib/python3.8/posixpath.py", line 152, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Process finished with exit code 1

 

 

I have seen other people that had issues with "Socket closed" errors, but usually those instances were resolved with renaming/deleting a script/code they had named 'code.py' or something to that effect. I don't believe that is the issue here. Any help or direction is greatly appreciated.

 

5 comments
Comment actions Permalink

Hi,

The issue seems to be the same as https://youtrack.jetbrains.com/issue/PY-44558, which is not fixed yet.

Does it help if you add PYDEVD_USE_CYTHON=NO environment variable to your run configuration (Run | Edit Configurations...)?


If not, try the workaround from this comment https://youtrack.jetbrains.com/issue/PY-44558#focus=Comments-27-4485084.0-0

1
Comment actions Permalink

Adding ;PYDEVD_USE_CYTHON=NO to the configuration seems to have been a sufficient work around. Is there way to set this as a sort of 'default' for a project? I'm assuming this is an error that will be addressed in future releases of Pycharm? Thanks for the help by the way! Sorry to post a redundant instance.

0
Comment actions Permalink

Sure, you can add it to the run configuration template. Each new run config will have it by default, but you still need to add it to the existing ones.

Yes, we'll fix it for sure, but I can't provide you with ETA yet.

1
Comment actions Permalink

Hi,

I'm trying to debug within pytest. Adding `PYDEVD_USE_CYTHON=NO` to the configuration stops the socket crashing, but the debugger is broken. Stepping into code takes me into pytest code rather than my application code. Will take a lot of time for me to rewrite fixtures to debug outside of pytest.

0
Comment actions Permalink

Peter Goodall

Could you please submit an issue to https://youtrack.jetbrains.com/issues/py with the code sample and steps to reproduce?

0

Please sign in to leave a comment.