42d5662571
This addresses the following: - Cleans up some minor typos - Normalizes the json code blocks - Removes unnecessary whitespace characters - Wraps `kbd` tags around instructions containing a plain text `F5` Note that for the `json` code block with comments – step 5 of the configure section, I changed the language to `js` so that the comments would render properly. |
||
---|---|---|
.. | ||
README.md |
README.md
Python debugging in VS Code
by Akshay Avinash (@akshay11298)
This recipe shows how to debug a Python application using the VS Code extension Python .
Getting Started
-
Make sure you have the latest version of VS Code installed.
-
Make sure you have the extension Python installed.
-
Optionally you can also install a linter to throw out the errors.
Configure VS Code debugging with a launch.json file
-
Click on the Debugging icon in the Activity Bar to bring up the Debug view.
-
Then click on the gear icon to configure a launch.json file, select Launch for the environment.
-
You may get an option of the environments available, select Python.
-
The generated json will have a lot of the configurations. You can keep all of them or only the ones you want.
{ "version": "0.2.0", "configurations": [ { "name": "Python: Current File (Integrated Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "integratedTerminal" }, { "name": "Python: Attach", "type": "python", "request": "attach", "port": 5678, "host": "localhost" }, { "name": "Python: Module", "type": "python", "request": "launch", "module": "enter-your-module-name-here", "console": "integratedTerminal" }, { "name": "Python: Django", "type": "python", "request": "launch", "program": "${workspaceFolder}/manage.py", "console": "integratedTerminal", "args": [ "runserver", "--noreload", "--nothreading" ], "django": true }, { "name": "Python: Flask", "type": "python", "request": "launch", "module": "flask", "env": { "FLASK_APP": "app.py" }, "args": [ "run", "--no-debugger", "--no-reload" ], "jinja": true }, { "name": "Python: Current File (External Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "externalTerminal" } ] }
-
For basic Python debugging of files, you will only need the following configuration:
{ // 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: Current File (Integrated Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "integratedTerminal" }, { "name": "Python: Current File (External Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "externalTerminal" } ] }
Start Debugging.
-
Open your Python file in VS Code.
-
Go to the Debug view, select the Start Debugging then press F5 or click the green play button.
-
VS Code should now show the rails server logs.
-
Go ahead and set a breakpoint in any of the files by clicking on the space before the line number. A red dot should appear to show a breakpoint.
-
Press F5 to start debugging.
-
Your breakpoint should now be hit.
-
To continue, press F5 again, till you reach the end.