Here’s how to set up debug configurations for each:
1. For Flask, create a launch configuration in your workspace folder with the following settings:
Name: Python Debugger: Flask
Type: debugpy
Request: Launch
Module: flask
Env: { “FLASK_APP”: “app.py” }
Args: [ “run”, “–no-debugger” ]
jinja: true (optional)
2. For Django, create a launch configuration with the following settings:
Name: Python Debugger: Django
Type: debugpy
Request: Launch
Program: ${workspaceFolder}/manage.py
Args: [ “runserver” ]
django: true (optional)
3. For Pyramid, create a launch configuration with the following settings:
Name: Python Debugger: Pyramid
Type: debugpy
Request: Launch
Program: ${workspaceFolder}/development.ini
jinja: true (optional)
pyramid: true (required)
4. For Gevent, add “gevent”: true to the standard integrated terminal configuration.
5. To debug a remote application, set up an SSH tunnel and configure your launch configuration with the following settings:
Name: Python Debugger: Attach
Type: debugpy
Request: Attach
Port: 5678 (or any other port you’re using for the SSH tunnel)
Host: localhost (since we set up an SSH tunnel, we use localhost here)
Path Mappings: [ { “localRoot”: “${workspaceFolder}”, “remoteRoot”: “.” } ]
6. To debug tests in your Python application, create a launch configuration with the following settings:
Name: Python Debugger: Tests
Type: debugpy
Request: Launch
Program: ${workspaceFolder}/tests/test_module.py (or any other test file)
Args: [ “unittest”, “-v” ]
7. To enable logpoints instead of print statements, use the Logpoint feature in VS Code’s debugger. A Logpoint is like a breakpoint except that it logs a message to the console and doesn’t stop the program. For more information, see Logpoints in the main VS Code debugging article.
8. To ensure your Python interpreter is detected correctly for debugging purposes, check which interpreter you have selected by running the Python: Select Interpreter command and looking at the current value. If necessary, configure your workspace’s settings to use a specific interpreter or environment.
9. For more information on debugging in Python, including configuring launch configurations and implementing remote debugging, see Debugging configurations. General VS Code debugging information is found in the debugging document.
10. If you encounter issues with debugging, such as invalid expressions in the watch window or a “timed out” error message when trying to apply a debugger to any running process on Linux systems, refer to the troubleshooting section for solutions.