vscode directory, create a file named launch.json if it does not already exist.
![how to debug python in visual studio code how to debug python in visual studio code](https://files.realpython.com/media/vscode-new-file.39cc7b9e485d.png)
vscode/settings.json file should have a line something like this: "python.pythonPath": "/Users/kmilligan/.virtualenvs/flask/bin/python" Select Preferences > Workspace Settings from the menu. Here’s how you can debug your app without modifying your code:įirst, be sure you have your virtual environment configured in VSCode (you are using a virtual environment, right?). Now that we have seen a few important details about VSCODE, it is time to configure Vscode for Python development. You could add a run script just for debugging, but that isn’t necessary. If you are using Flask 0.11.x, chances are you use the new “flask” command to launch your app. It is used to develop computer programs, websites, web apps, web services, and mobile apps. The simplest way to run and debug a simple Python script is going to the Run Start Debugging menu and choosing Python File from the selection. If you write code on Windows, there is a high probability that you work on Visual Studio. Debugging Your Python Scripts in Visual Studio Code The Python extension for Visual Studio Code comes bundled with a powerful debugger that supports local and remote debugging. Open the directory in Visual Studio Code Modify the run.py file as follows: flask/bin/python from app import app Do not add debugTrue app.run(debugTrue) app. Press any key to close the output window.
![how to debug python in visual studio code how to debug python in visual studio code](https://blog.miguelgrinberg.com/static/images/vscode-screenshot.gif)
As of yet, nothing has been done to pause the program while its running, it will just print a wave pattern for a few iterations. This command runs the code in the debugger.
#HOW TO DEBUG PYTHON IN VISUAL STUDIO CODE HOW TO#
Originally documented by KEATH MILLIGAN on 13 October 2016 In this article, we explain how to build applications with OpenCV using Visual Studio. Check that the code works properly by pressing F5 or selecting the Debug > Start Debugging menu command. Debugging Flask Applications is as simple as debugging any other Python Application.