You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
can't run python4andorid in debugger in vscode because shprint does not seem to work well in debugpy #3175
The debgger used in vscode, debugpy, seems to not be able to run bulldozer because of code in python-for-android. When running a build sh.basename is called in the python3 recipe. The code is a more complex version of this code:
When running without the debugger this works fine, but with the debugger I get:
cd /home/guy/workspace/hand_tracker ; /usr/bin/env /home/guy/vpy/bin/python /home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 59539 -- /tmp/reproduce.py
[INFO]: -> running basename /a/Python-3.11.5.tgz
Traceback (most recent call last):
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 422, in _on_run
cmd.send(self.sock)
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py", line 111, in send
sock.sendall(("Content-Length: %s\r\n\r\n" % len(as_bytes)).encode("ascii"))
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53, in run
self._on_run()
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 432, in _on_run
self.py_db.dispose_and_kill_all_pydevd_threads()
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2558, in dispose_and_kill_all_pydevd_threads
self._client_socket.close()
File "/usr/lib/python3.11/socket.py", line 503, in close
self._real_close()
File "/usr/lib/python3.11/socket.py", line 497, in _real_close
_ss.close(self)
OSError: [Errno 9] Bad file descriptor
6.71s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Python-3.11.5.tgz
I found another way to debug this. You can also do it remotely.
Steps to reproduce.
Run this script on your system:
frompythonforandroid.loggerimportshprintimportdebugpy# Add this at the beginning of your main.py, but after any Kivy importsdefenable_remote_debugging():
try:
debugpy.listen(("0.0.0.0", 5678))
print("Waiting for debugger to attach at 0.0.0.0:5678...")
debugpy.wait_for_client()
print("Debugger attached!")
exceptExceptionase:
print(f"Debugpy error: {e}")
# Call this function early in your app initializationenable_remote_debugging()
importshprint(shprint(sh.basename, '/a/Python-3.11.5.tgz'))
On vscode open a debug session with these launch settings:
python3 /tmp/reproduce.py
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Waiting for debugger to attach at 0.0.0.0:5678...
Debugger attached!
[INFO]: -> running basename /a/Python-3.11.5.tgz
Traceback (most recent call last):
File "/home/guy/vpy/lib/python3.11/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 422, in _on_run
cmd.send(self.sock)
File "/home/guy/vpy/lib/python3.11/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py", line 111, in send
sock.sendall(("Content-Length: %s\r\n\r\n" % len(as_bytes)).encode("ascii"))
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/guy/vpy/lib/python3.11/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53, in run
self._on_run()
File "/home/guy/vpy/lib/python3.11/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 432, in _on_run
self.py_db.dispose_and_kill_all_pydevd_threads()
File "/home/guy/vpy/lib/python3.11/site-packages/debugpy/_vendored/pydevd/pydevd.py", line 2558, in dispose_and_kill_all_pydevd_threads
self._client_socket.close()
File "/usr/lib/python3.11/socket.py", line 503, in close
self._real_close()
File "/usr/lib/python3.11/socket.py", line 497, in _real_close
_ss.close(self)
OSError: [Errno 9] Bad file descriptor
22.59s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Python-3.11.5.tgz
It looks like some failure due to debugpy. But it only happends if there is these lines:
import sh
print(shprint(sh.basename, '/a/Python-3.11.5.tgz'))
Activity
guysoft commentedon Jul 23, 2025
I found another way to debug this. You can also do it remotely.
Steps to reproduce.
The stdout of the python script above is:
It looks like some failure due to debugpy. But it only happends if there is these lines:
And they appear in buildozer