Debugging Azure functions in PyCharm professional
I read many posts about this and they generally point to two solutions:
1. using a debugging server, like in this article: https://medium.com/@m.s.cuckson/debugging-azure-functions-in-pycharm-c666e1cc5d98
2. attach to a running process using Run | Attach to a process
I know many had success with both but I am unable to do either of this. With option 1, when I make an HTTP request to the locally deployed server, the process is hangs and no break points are hit. With option 2, I get this error that I don't understand:
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Inappropriate ioctl for device.
Target 'None' cannot support this command.
No symbol table is loaded. Use the "file" command.
No symbol table is loaded. Use the "file" command.
Traceback (most recent call last):
File "/home/zz/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py", line 79, in <module>
main(process_command_line(sys.argv[1:]))
File "/home/zz/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py", line 74, in main
add_code_to_python_process.run_python_code(
File "/home/zz/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/add_code_to_python_process.py", line 476, in run_python_code_linux
subprocess.check_call(' '.join(cmd), shell=True, env=env)
File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'gdb --nw --nh --nx --pid 362261 --batch --eval-command='set scheduler-locking off' --eval-command='set architecture auto' --eval-command='call (void*)dlopen("/home/zz/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_linux_amd64.so", 2)' --eval-command='sharedlibrary attach_linux_amd64' --eval-command='call (int)DoAttach(0, "import sys;sys.path.append(\"/home/zz/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python-ce/helpers/pydev\");sys.path.append(\"/home/zz/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=34813, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");", 0)'' returned non-zero exit status 1.
This is getting frustrating because my azure function is growing bigger and difficult to debug, and I just started ‘free trial’ professional because it is feature unavailable on the community version. But so far the results have been disappointing.
My pycharm professional version is 2024.3.1.1
If anyone had success recently, please can you share some tips?
Many many thanks
Please sign in to leave a comment.
Hi ZZ
Does it look similar to PY-77357? Please try to disable
python.debug.use.single.port
in registry:1. Press "Shift-Shift" on keyboard > type
registry
and hit Enter to open the Registry window.2. Start typing to find the following option and disable it:
python.debug.use.single.port
Please try to enable ptrace_scope as per these instructions. Does it help?
Yes that works, thank you so much!!