Debugpy无法附加,VSCode调试Django项目断点失效求助
VSCode调试Docker中的Django应用无法触发断点
尝试了各种方法均无效,VSCode调试器无法触发任何断点。以下是相关配置文件及代码:
launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python: Docker", "type": "python", "request": "attach", "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "/code" } ], "connect": { "host": "localhost", "port": 3000 }, "justMyCode": true, "logToFile": true } }
docker-compose.yml
services: web: platform: linux/amd64 build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - 8800:8000 - 3000:3000
manage.py 代码片段
if settings.DEBUG: if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'): import debugpy debugpy.listen(("0.0.0.0", 3000)) # debugpy.wait_for_client() print('debugpy Attached!')
控制台已打印debugpy Attached!,说明Debugpy已加载,但断点仍无法触发。另外测试Django管理命令python manage.py myCommand,尝试用python -m debugpy --listen 0.0.0.0:3000 manage.py myCommand启动仍无效。
内容的提问来源于stack exchange,提问作者AlxVallejo
相关产品推荐
相关产品推荐

