2

I would like to pass the "-q -X faulthandler" arguments to the python interpreter in VS code launch.json but I have not found a solution yet (args passes argument to the .py file).

So the command would look like this in the teminal:

python** -q -X faulthandler** main.py --arg1 --arg2

Thank you!

I've read the VS code documentation but I have not found any description for this. I've tried to execute the python script in VS code with the following lauch.json options (neither worked):

1, "type": "python -q -X faulthander", "cwd": "${workspaceRoot}", "request": "launch", "program": "main.py",

2, "type": "python", "cwd": "${workspaceRoot}", "request": "launch", "program": "- q -X faulthandler main.py",

2
  • pythonArgs: Specifies arguments to pass to the Python interpreter using the syntax "pythonArgs": ["<arg 1>", "<arg 2>",...]. Commented Dec 13, 2022 at 9:09
  • Hi JialeDu! Thank you so much! I should have read the documentation twice! Commented Dec 13, 2022 at 11:46

1 Answer 1

0

According to the official documentation, in launch.json you can add pythonArgs configuration to specify parameters for the interpreter.

Another way is to install the Code Runner extension, and then search for Code-runner: Custom Command in setting to customize the execution command.

enter image description here

Or add the following configuration directly in settings.json to have the same effect.

    "code-runner.customCommand": "python $fileName",

After the configuration is complete, use Ctrl+Shift+P --> Run: Cunstom Command(Ctrl + Alt + K) to execute the code.

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Hi.Thanks! I am testing it. In general I do not like that VS code does not properly show what is the command that is executed in its terminal so I can not see wether these arguments are really passed to the interpreter. I've found someone reporting a bug recently github.com/microsoft/vscode-python/issues/19810... so I tried with python.terminal.launchArgs fist. Unfortunately this does not seem to pass the params. (code stopped with no warnings/error but in the native terminal window I god a proper error message). So now I try with "pythonArgs": ["-q", "-X", "faulthandler"]. let's see..
The "pythonArgs": ["-q", "-X", "faulthandler"] works fine! Also VS code displays the error! Thanks once again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.