My question may seem simple but, I have a module that I launch in a terminal like this:
python -m my_module.my_file
How do I debug this in Visual Studio Code?
I have this in my launch.json
(documentation)
"type": "python", "request": "launch", "pythonPath": "D:\\ProgramData\\Anaconda3\\envs\\simulec\\python.exe", "args": [ "-m", "my_module.my_file", ]
If I don't set the program
option or if I set it to ""
I get "File does not exist" Error.
How can I fix this?
Python in Visual Studio supports debugging without a project. With a stand-alone Python file open, right-click in the editor, select Start with Debugging, and Visual Studio launches the script with the global default environment (see Python environments) and no arguments.
Try putting your JSON file's content into a validator, like http://jsonlint.com/ or http://jsonformatter.curiousconcept.com/ and see what it says. Show activity on this post. I suggest entering your JSON into a linter such as http://jsonlint.com/.
Actually, there is a very simple option to do this I found by accident while trying to edit the launch.json
file.
"type": "python", "request": "launch", "pythonPath": "D:\\ProgramData\\Anaconda3\\envs\\simulec\\python.exe", "module": "my_module.my_file",
Simply specify the module in the module key "module": "my_module.my_file"
The -m
is not useful any more.
In a terminal like this: python -m xyz abc.z3
(Please make sure you are opening "the root folder of your project").
{ // 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": "module", "type": "python", "request": "launch", "module": "xyz", "args": [ "abc.z3" ] } ], }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With