user1547462
user1547462

Reputation:

VS Code debug python script configuration ignores args attribute

I am trying to debug a python3 script I wrote that requires command line arguments without success. I found VSCode: How debug Python script with arguments when searching stackoverflow and it points out that the attribute args should be set to a list of arguments. However when I run the debug config that I created to debug a script under ./scripts I get back the argparse error the following arguments are required: database, media_url, images. And I am not sure what I am overlooking

{
    // 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": "Populate Database Script Debug",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/scripts/populate_sqlite.py",
            "console": "integratedTerminal",
            "args": ["db.sqlite3", "../tarot_juicer/static/img", "~/slipsnip/automation/tarot/out"],
            "cwd": "${workspaceFolder}/scripts/"
        }
    ]
}

on the same subject of debuging python with vscode I also noted that when my populate_sqlite.py script attempts to read a file data.csv which exists in the same directory as the script, I get the FileNotFoundError: [Errno 2] File data.csv does not exist: 'data.csv' however if in the terminal I navigate into the script directory before running the debug config, that problem is solved though I am still left with the subject problem of this question, why is args being ignored?

If someone can explain how to fix the problem of my arguments not being passed to the script upon debug execution that would be greatly appreciated. If someone could also lead me in the right direction as to how can I have files in the cwd exist without having to cd into the script directory that would also be greatly appreciated. Thank you.

Upvotes: 3

Views: 1527

Answers (1)

user1547462
user1547462

Reputation:

It seems to have corrected itself, having returned to the project today after a reboot. Perhaps vscode needed to be restarted, the problem has gone away and args are now being passed.

Upvotes: 4

Related Questions