You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Python extension makes Visual Studio Code an excellent Python editor, works on any operating system, and is usable with a variety of Python interpreters.
-[Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) from the VS Code Marketplace
21
+
22
+

22
23
23
24
To further customize VS Code for Python, you can leverage the [Python profile template](/docs/editor/profiles.md#python-profile-template), automatically installing recommended extensions and settings. For Data Science projects, consider using the [Data Science profile template](/docs/editor/profiles.md#data-science-profile-template).
24
25
25
-

26
+

26
27
27
28
## How to create and open a Python project or file
28
29
@@ -36,7 +37,7 @@ You can create a new Python file by selecting **New File** on the VS Code Welcom
36
37
37
38
When you launch VS Code for the very first time, you will need to install the Python extension to get Python-specific features and UI. Let’s look at the UI after installing the Python extension:
38
39
39
-

40
+

40
41
41
42
## Code Actions
42
43
@@ -48,7 +49,7 @@ Code Actions (also known as Quick Fixes) are provided to help fix issues when th
48
49
49
50
Python commands can be accessed through the [Command Palette](/docs/getstarted/userinterface.md#command-palette) (`kb(workbench.action.showCommands)`). From the Command Palette, you have access to various features from VS Code and installed extensions. Enter **“Python: “** in the Command Palette to find the commands available through the Python extension.
50
51
51
-

52
+

52
53
53
54
## Run, debug, and test
54
55
@@ -63,14 +64,15 @@ To run the Python script you have open on the editor, select the **Run Python Fi
63
64

64
65
65
66
There are also additional ways you can iteratively run snippets of your Python code within VS Code:
66
-
- Select one or more lines, then press `kbstyle(Shift+Enter)` or right-click and select **Run Selection/Line in Python Terminal**. This command is convenient for testing just a part of a file.
67
-
- From the Command Palette (`kb(workbench.action.showCommands)`), select the **Python: Start REPL** command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
67
+
68
+
- Select one or more lines, then press `kbstyle(Shift+Enter)` or right-click and select **Run Selection/Line in Python Terminal**. This command is convenient for testing just a part of a file.
69
+
- From the Command Palette (`kb(workbench.action.showCommands)`), select the **Python: Start REPL** command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
68
70
69
71
### Debug
70
72
71
73
The debugger is a helpful tool that allows you to inspect the flow of your code execution and more easily identify errors, as well as explore how your variables and data change as your program is run. You can start debugging by setting a breakpoint in your Python project by clicking in the gutter next to the line you wish to inspect.
72
74
73
-

75
+

74
76
75
77
To start debugging, initialize the debugger by pressing `kbstyle(F5)`. Since this is your first time debugging this file, a configuration menu will open allowing you to select the type of application you want to debug. If it's a Python script, you can select **Python File**.
76
78
@@ -81,13 +83,14 @@ Once your program reaches the breakpoint, it will stop and allow you to track da
81
83
For a deeper dive into Python debugging functionality, see [Python debugging in VS Code](/docs/python/debugging.md).
82
84
83
85
### Test
86
+
84
87
The Python extension provides robust testing support for [Unittest](https://docs.python.org/3.3/library/unittest.html) and [pytest](https://pytest.org/en/7.4.x/).
85
88
86
89
You can configure Python tests through the Testing view on the Activity Bar by selecting **Configure Python Tests** and selecting your test framework of choice.
87
90
88
91
You can also create tests for your Python project, which the Python extension will attempt to discover once your framework of choice is configured. The Python extension also allows you to run and debug your tests in the Testing view and inspect the test run output in the Test Results panel.
89
92
90
-

93
+

91
94
92
95
For a comprehensive look at testing functionality, see [Python testing in VS Code](/docs/python/testing.md).
93
96
@@ -107,6 +110,3 @@ There is much more to explore with Python in Visual Studio Code:
107
110
-[Debugging](/docs/python/debugging.md) - Learn to debug Python both locally and remotely.
108
111
-[Testing](/docs/python/testing.md) - Configure test environments and discover, run, and debug tests.
109
112
-[Settings reference](/docs/python/settings-reference.md) - Explore the full range of Python-related settings in VS Code.
0 commit comments