Can't run Debugger - 'Connection to Python debugger failed; Socket closed'
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.
请先登录再写评论。
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.
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
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.
Working for me: delete the Path in Working directory of your run/debug configuration
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.
Peter Goodall
Could you please submit an issue to https://youtrack.jetbrains.com/issues/py with the code sample and steps to reproduce?
Thanks, Sergey Karpov! The photo helped me to fix the issue.
i moved my files to primary location of pycharm and debugging works!!
before that my files was on personal location that i made .
I face this issue always in PyCharm as ‘Connection to Python debugger failed : Socket closed’
I tried changing the environment variable to PYDEVD_USE_CYTHON=NO
Still faced the same issue
And tried changing the environment variable to PYTHONUNBUFFERED=1
Still faced the same issue
I face the below error in console after debugging the code .
I tried unticking PyQT compatibility also in Python Debugger and still face the issue for debugging.
Please anyone help me with further recoveries please
Siddhusir23 It seems the issue happens when importing ctypes. Please try running Python from “C:\Program Files\Python311” and execute “import ctypes”. Does it work?
Yeah its not working and throws the same system error.
Program is running from C:ProgramFiles\Python311\python.exe
But still face this ctype error.
any environment variable to change please let me know.
Can you please help me with this ctypes part and how to resolve on this
Still facing the same issue on Idea CE : 'Connection to Python debugger failed; Socket closed'
For me it worked after reinstalling / restarting Pycharm with New Project.
Try running Py in Virtual Environment.
Thanks !
Also, removing the run configuration for your file (Run | Edit Configurations) and regenerating it again by running a file with the default run config might be helpful.