cpfert.blogg.se

Python script debugger
Python script debugger










Here, you can select the appropriate option to quickly debug your code. When no configuration has been set, you'll be given a list of debugging options. If you're looking to debug a web application using Flask, Django or FastAPI, the Python extension provides dynamically created debug configurations based on your project structure under the Show all automatic debug configurations option, through the Run and Debug view.īut if you're looking to debug other kinds of applications, you can start the debugger through the Run view by clicking on the Run and Debug button. If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal. Alternately, select the named interpreter on the Status Bar to select a different one. To use a different interpreter for debugging specifically, set the value for python in launch.json for the applicable debugger configuration.

python script debugger

Selecting the configuration brings up a list from which you can choose a different configuration:īy default, the debugger uses the same interpreter selected for your workspace, just like other features of Python extension for VS Code. See Debugging specific app types for details on all of these configurations.ĭuring debugging, the Status Bar shows the current configuration and the current debugging interpreter. Selecting the Attach using Process ID one yields the following result:

Python script debugger code#

When you use the command, VS Code prompts you with a list of all available configurations (be sure to select the Python option): You can select other configurations to include in launch.json by using the Add Configuration command shown in the list and the launch.json editor. Additional configurationsīy default, VS Code shows only the most common configurations provided by the Python extension. Other configurations are also described in this article under Debugging specific app types. The details of configuration properties are covered later in this article under Standard configuration and options. You can modify configurations (to add arguments, for example), and also add custom configurations. The Python extension then creates and opens a launch.json file that contains a pre-defined configuration based on what you previously selected, in this case, Python File. Note: Starting a debugging session through the Debug Panel, F5 or Run > Start Debugging when no configuration exists will also bring up the debug configuration menu, but will not create a launch.json file. For now, in the Select a debug configuration menu that appears, select Python File. Select the create a launch.json file link (outlined in the image above) or use the Run > Open configurations menu command.Ī configuration menu will open from the Command Palette allowing you to choose the type of debug configuration you want for the opened file. To generate a launch.json file with Python configurations, do the following steps: If you don't yet have any configurations defined, you'll see a button to Run and Debug and a link to create a configuration (launch.json) file: To initialize debug configurations, first select the Run view in the sidebar:

python script debugger

Note: To change debugging configuration, your code must be stored in a folder. Configurations are defined in a launch.json file that's stored in a.

python script debugger

Initialize configurationsĪ configuration drives VS Code's behavior during a debugging session. This article mainly addresses Python-specific debugging configurations, including the necessary steps for specific app types and remote debugging. Both tutorials demonstrate core skills like setting breakpoints and stepping through code.įor general debugging features such as inspecting variables, setting breakpoints, and other activities that aren't language-dependent, review VS Code debugging. For a short walkthrough of basic debugging, see Tutorial - Configure and run the debugger. The Python extension supports debugging of several types of Python applications.

  • Configure IntelliSense for cross-compiling.









  • Python script debugger