55※ Change to the IP address (v4) specified by your WSL2
66
77#### Check python's parent process ID at startup
8-
98``` markdown
109import os
1110
@@ -15,6 +14,34 @@ pid = os.getppid()
1514# Need to check at startup
1615print(f"Parent Process ID: {pid}")
1716```
17+ ### Add this to the top of your python file to start debugging
18+ ``` python
19+ import debugpy
20+ import os
21+
22+ from typing import Optional```
23+ def debug_wait_for_attach (listen_to ):
24+ scoop = os.path.expanduser(' ~/scoop/apps/python/current/python.exe' )
25+ pyenv: Optional[str ] = os.path.expanduser(' /.pyenv/shims/python' )
26+ ay: Optional[str ] = os.path.expanduser(' /.anyenv/envs/pyenv/shims/python' )
27+
28+ if os.path.exists(os.path.expanduser(scoop)):
29+ # use scoop
30+ debugpy.configure(python = str (scoop))
31+ debugpy.listen(listen_to)
32+ debugpy.wait_for_client()
33+ elif os.path.exists(pyenv):
34+ # ~/.pyenv
35+ debugpy.configure(python = str (pyenv))
36+ debugpy.listen(listen_to)
37+ debugpy.wait_for_client()
38+ elif os.path.exists(ay):
39+ # ~/.anyenv
40+ debugpy.configure(python = str (ay))
41+ debugpy.listen(listen_to)
42+ debugpy.wait_for_client()
43+ ```
44+ ※ scoop/.pyenv/anyenv, add other paths yourself
1845
1946> python -m debugpy --wait-for-client --listen 5678 facematch.py ${@:2}
2047
0 commit comments