简体   繁体   English

使用VsCode调试python模块

[英]Debugging python module with VsCode

I am trying to debug a python program that takes a module as argument ( see args ). 我正在尝试调试将模块作为参数的python程序(请参阅args )。 The launch.json config is below: launch.json配置如下:

{
        "name": "Python: Actions",
        "type": "python",
        "request": "launch",
        "module": "my_module",
        "args": [
            "--module",
            "module"
        ],
        "cwd": "/cwd",
        "console": "integratedTerminal"
},

When I run the program like this it works: python -m my_module --module module 当我像这样运行程序时,它可以正常工作:python -m my_module --module module

However, when I launch the debug config, it can't find the module passed as argument. 但是,当我启动调试配置时,它找不到作为参数传递的module Here is command line statement issued by vscode when I launch de config: 这是我启动de config时vscode发出的命令行语句:

cd /cwd ; env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1" /path/to/python ~/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 60664 -m my_module --module module

At the moment, VSCode's CLI parser needs a little help to avoid confusing its arguments with the module's: 目前,VSCode的CLI解析器需要一点帮助,以避免将其参数与模块的混淆:

{
        "name": "debugging-my-module",
        "type": "python",
        "request": "launch",
        "module": "my_module",
        "args": [
            "--"
            "optional", 
            "args",
            "for",
            "your",
            "module",
        ],
        "console": "integratedTerminal"
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM