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
Copy file name to clipboardExpand all lines: docs/python/tutorial-working-with-python-in-visual-studio-step-01-create-project.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,30 @@
1
1
---
2
-
title: Python in Visual Studio tutorial Step 1, create a project
2
+
title: "Tutorial: Create a Project Python in Visual Studio"
3
3
titleSuffix: ""
4
-
description: Overview and Step 1 of a core walkthrough of Python capabilities in Visual Studio, including prerequisites and creating a new Python project.
4
+
description: Explore step 1 of a tutorial about Python capabilities in Visual Studio, including prerequisites and creating a new Python project.
5
5
author: cwebster-99
6
6
ms.author: cowebster
7
7
ms.subservice: python
8
8
ms.topic: tutorial
9
-
ms.date: 04/18/2024
9
+
ms.date: 07/29/2025
10
10
manager: mijacobs
11
11
ms.custom: vs-acquisition
12
12
13
13
# CustomerIntent: As a developer, I want to create Python applications and projects in Visual Studio so I can support my Python development needs.
14
14
---
15
15
16
-
# Tutorial: Work with Python in Visual Studio
16
+
# Part 1: Work with Python in Visual Studio
17
17
18
-
This article is the first step in a sixpart tutorial series that demonstrates how to work with Python in Visual Studio. Python is a popular programming language that's reliable, flexible, easy to learn, and free to use on all operating systems. A strong developer community and many free libraries provide robust support for working with Python. The language supports all kinds of development, including web applications, web services, desktop apps, scripting, and scientific computing. Many universities, scientists, casual developers, and professional developers use Python. Visual Studio provides first-class language support for Python.
18
+
This article is the first step in a six-part tutorial series that demonstrates how to work with Python in Visual Studio. Python is a popular programming language that's reliable, flexible, easy to learn, and free to use on all operating systems. A strong developer community and many free libraries provide robust support for working with Python. The language supports all kinds of development, including web applications, web services, desktop apps, scripting, and scientific computing. Many universities, scientists, casual developers, and professional developers use Python. Visual Studio provides first-class language support for Python.
19
19
20
20
The six parts in the tutorial series include:
21
21
22
22
-[Step 1: Create a Python project (this article)](#create-a-new-python-project)
23
-
-[Step 2: Write and run code to see Visual Studio IntelliSense at work](tutorial-working-with-python-in-visual-studio-step-02-writing-code.md)
24
-
-[Step 3: Create more code in the Interactive REPL window](tutorial-working-with-python-in-visual-studio-step-03-interactive-repl.md)
25
-
-[Step 4: Run the completed program in the Visual Studio debugger](tutorial-working-with-python-in-visual-studio-step-04-debugging.md)
26
-
-[Step 5: Install packages and manage Python environments](tutorial-working-with-python-in-visual-studio-step-05-installing-packages.md)
27
-
-[Step 6: Work with Git](tutorial-working-with-python-in-visual-studio-step-06-working-with-git.md)
23
+
-[Step 2: Write and run Python code in Visual Studio](tutorial-working-with-python-in-visual-studio-step-02-writing-code.md)
24
+
-[Step 3: Use the Interactive REPL window](tutorial-working-with-python-in-visual-studio-step-03-interactive-repl.md)
25
+
-[Step 4: Run code in the Visual Studio debugger](tutorial-working-with-python-in-visual-studio-step-04-debugging.md)
26
+
-[Step 5: Install packages in your Python environment](tutorial-working-with-python-in-visual-studio-step-05-installing-packages.md)
27
+
-[Step 6: Work with Git in Visual Studio](tutorial-working-with-python-in-visual-studio-step-06-working-with-git.md)
28
28
29
29
In Step 1 of the tutorial, you learn how to:
30
30
@@ -42,9 +42,9 @@ This tutorial begins by creating a simple project that contains a single, empty
42
42
43
43
::: moniker range="<=vs-2019"
44
44
45
-
1. In Visual Studio, select **File** > **New** > **Project** to open the **New Project** dialog. You can also use the keyboard shortcut **Ctrl**+**Shift**+**N**. In the dialog, you can browse templates across different languages, select a template for your project, and specify where Visual Studio places files.
45
+
1. In Visual Studio, select **File** > **New** > **Project** to open the **New Project** dialog. You can also use the keyboard shortcut **Ctrl**+**Shift**+**N**. In the dialog box, you can browse templates across different languages, select a template for your project, and specify where Visual Studio places files.
46
46
47
-
1. To view Python templates, select **Installed** > **Python** on the left menu, or search for "Python." The search option is a great way to find a template when you can't remember its location in the languages tree.
47
+
1. To view Python templates, select **Installed** > **Python** on the left menu, or search for *Python*. The search option is a great way to find a template when you can't remember its location in the languages tree.
48
48
49
49
:::image type="content" source="media/tutor-python-1-create-project.png" alt-text="Screenshot showing the Create a new project dialog box with Python project templates." lightbox="media/tutor-python-1-create-project.png":::
50
50
@@ -56,10 +56,10 @@ This tutorial begins by creating a simple project that contains a single, empty
56
56
::: moniker range=">=vs-2022"
57
57
58
58
1. In Visual Studio, select **File** > **New** > **Project** or use the keyboard shortcut **Ctrl**+**Shift**+**N**. The **Create a new project** screen opens, where you can search and browse templates across different languages.
59
-
59
+
60
60
1. To view Python templates, search for *python*. Search is a great way to find a template when you can't remember its location in the languages tree.
61
61
62
-
:::image type="content" source="media/vs-2022/tutor-python-1-create-project-2022.png" alt-text="Screenshot showing the Create a new project dialog box in Visual Studio 2022 with Python project templates." lightbox="media/vs-2022/tutor-python-1-create-project-2022.png":::
62
+
:::image type="content" source="media/vs-2022/tutor-python-1-create-project-2022.png" alt-text="Screenshot showing the Create a new project dialog box in Visual Studio with Python project templates." lightbox="media/vs-2022/tutor-python-1-create-project-2022.png":::
63
63
64
64
Python web support in Visual Studio includes several project templates, such as web applications in the Bottle, Flask, and Django frameworks. When you install Python with the Visual Studio Installer, select **Python Web Support** under **Optional** to install these templates. For this tutorial, start with an empty project.
65
65
@@ -103,29 +103,29 @@ Take some time to familiarize yourself with **Solution Explorer**. This window i
103
103
104
104
::: moniker-end
105
105
106
-
1. In **Solution Explorer** (**1**), notice the toplevel item in the structure. This item is your Visual Studio _solution_. By default, your solution name is the same as your project.
107
-
106
+
1. In **Solution Explorer** (**1**), notice the top-level item in the structure. This item is your Visual Studio _solution_. By default, your solution name is the same as your project.
107
+
108
108
A solution, which is shown as an _.sln_ file on disk, is a container for one or more related projects. For example, if you write a C++ extension for your Python application, that C++ project can be in the same solution. The solution might also contain a project for a web service, and projects for dedicated test programs.
109
-
109
+
110
110
1. Locate the item directly under the solution name. This item is your project (**2**). Your project name is the name you entered in the **Create a new project** dialog. Visual Studio uses bold to identify the currently selected project in your solution.
111
111
112
112
On disk, a _.pyproj_ file in your project folder represents the project.
113
113
114
114
1. Toggle the **Expand/Collapse** arrow next to the project name to view your project source files.
115
115
116
-
Visual Studio uses bold to identify which file is the _Start File_ for the program. In this example, you have only a single _.py_ file. (**3**)
117
-
116
+
Visual Studio uses bold to identify which file is the _Start File_ for the program. In this example, you have only a single _.py_ file (**3**).
117
+
118
118
1. To view the properties for a file in the **Properties** window, select the file in **Solution Explorer**.
119
119
120
120
If you don't see the **Properties** window, select the wrench icon in the **Solution Explorer** banner. Double-clicking a file opens it in whatever way is appropriate for that file.
121
-
122
-
1. Under your project node, locate the **Python Environments** node.**(4)** Expand the node to show the available Python interpreters.
123
-
124
-
1. Under the **Python Environments** node, expand an interpreter node to see the libraries installed in that environment. (**5**)
125
-
121
+
122
+
1. Under your project node, locate the **Python Environments** node **(4)**. Expand the node to show the available Python interpreters.
123
+
124
+
1. Under the **Python Environments** node, expand an interpreter node to see the libraries installed in that environment (**5**).
125
+
126
126
Right-click any node or item in **Solution Explorer** to show a context menu of applicable commands. For example, **Rename** lets you change the name of a node or item, including the project and the solution.
127
127
128
128
## Next step
129
129
130
130
> [!div class="nextstepaction"]
131
-
> [Step 2: Write and run code](tutorial-working-with-python-in-visual-studio-step-02-writing-code.md)
131
+
> [Step 2: Write and run Python code](tutorial-working-with-python-in-visual-studio-step-02-writing-code.md)
Copy file name to clipboardExpand all lines: docs/python/tutorial-working-with-python-in-visual-studio-step-02-writing-code.md
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: Python in Visual Studio tutorial Step 2, write and run code
2
+
title: "Tutorial Step 2: Write and Run Python Code"
3
3
titleSuffix: ""
4
-
description: Step 2 of a core walkthrough of Python capabilities in Visual Studio that demonstrates how to edit code and run a project.
5
-
ms.date: 04/18/2024
4
+
description: Explore step 2 of a tutorial about Python capabilities in Visual Studio that demonstrates how to edit code and run a project.
5
+
ms.date: 07/29/2025
6
6
ms.topic: tutorial
7
7
author: cwebster-99
8
8
ms.author: cowebster
@@ -16,7 +16,9 @@ ms.subservice: python
16
16
17
17
This article presents Step 2 in the tutorial series _Work with Python in Visual Studio_.
18
18
19
-
The Visual Studio interactive development environment (IDE) provides various windows that support different development tasks. [Step 1 in the tutorial](tutorial-working-with-python-in-visual-studio-step-01-create-project.md) describes how to manage project files in the **Solution Explorer** window. In Step 2, you use the _editor_ window to work with the _contents_ of files, like source code. The editor is contextually aware of the type of file you're editing. The editor also recognizes the programming language (based on the file extension), and offers features appropriate to that language such as syntax coloring and auto-completion by using IntelliSense.
19
+
The Visual Studio integrated development environment (IDE) provides various windows that support different development tasks. [Step 1 in the tutorial](tutorial-working-with-python-in-visual-studio-step-01-create-project.md) describes how to manage project files in the **Solution Explorer** window. In Step 2, you use the _editor_ window to work with the _contents_ of files, like source code.
20
+
21
+
The editor is contextually aware of the type of file you're editing. The editor also recognizes the programming language (based on the file extension), and offers features appropriate to that language such as syntax coloring and autocompletion by using IntelliSense.
20
22
21
23
In Step 2 of the tutorial, you learn how to:
22
24
@@ -39,19 +41,19 @@ Follow these steps to start writing Python code:
39
41
40
42
1. In the editor, start to enter the Python function name `print`.
41
43
42
-
As you enter the function name, Visual Studio IntelliSense displays auto-completion options for your code. The default completion option is highlighted:
44
+
As you enter the function name, Visual Studio IntelliSense displays autocompletion options for your code. The default completion option is highlighted:
43
45
44
-
:::image type="content" source="media/tutor-python-2-intellisense-print-completion.png" alt-text="Screenshot that shows IntelliSense auto-completion options in the editor in Visual Studio. The default completion option is highlighted." border="false" lightbox="media/tutor-python-2-intellisense-print-completion.png":::
46
+
:::image type="content" source="media/tutor-python-2-intellisense-print-completion.png" alt-text="Screenshot that shows IntelliSense autocompletion options in the editor in Visual Studio. The default completion option is highlighted." lightbox="media/tutor-python-2-intellisense-print-completion.png":::
45
47
46
48
To apply the default completion to your code, select the **Tab** keyboard shortcut.
47
-
49
+
48
50
Completions are most helpful when you need to add longer statements or identifiers in your code. IntelliSense shows different completion options based on the statement you're using. For example, when you use parenthesis `()` with a function name, Intellisense recognizes the code as a function call.
49
51
50
52
1. In the editor, start to enter code to call the `print()` function.
51
53
52
54
When you enter the open parenthesis `(`, Intellisense shows full usage information for the function. The current argument is in boldface. In this example, the argument is **values: object**:
53
55
54
-
:::image type="content" source="media/tutor-python-2-intellisense-argument-completion.png" alt-text="Screenshot that shows IntelliSense auto-completion options for the print function in the editor in Visual Studio." border="false" lightbox="media/tutor-python-2-intellisense-argument-completion.png":::
56
+
:::image type="content" source="media/tutor-python-2-intellisense-argument-completion.png" alt-text="Screenshot that shows IntelliSense autocompletion options for the print function in the editor in Visual Studio." lightbox="media/tutor-python-2-intellisense-argument-completion.png":::
55
57
56
58
1. In the editor, complete the code statement so it matches the following example:
57
59
@@ -65,7 +67,7 @@ Follow these steps to start writing Python code:
65
67
66
68
Notice how Visual Studio shows a red underline for code that contains syntax errors.
67
69
68
-
:::image type="content" source="media/tutor-python-2-intellisense-colors-highlights.png" alt-text="Screenshot that shows IntelliSense syntax coloring and error highlighting in the editor in Visual Studio." border="false" lightbox="media/tutor-python-2-intellisense-colors-highlights.png":::
70
+
:::image type="content" source="media/tutor-python-2-intellisense-colors-highlights.png" alt-text="Screenshot that shows IntelliSense syntax coloring and error highlighting in the editor in Visual Studio." lightbox="media/tutor-python-2-intellisense-colors-highlights.png":::
69
71
70
72
1. Replace the closing quote mark `"` in your code.
71
73
@@ -98,7 +100,7 @@ After you have some code in place, you're ready to try running your program. You
98
100
99
101
1. When you run the program, a console window opens to show the results. This window is similar to what you see when you run a Python interpreter with the Python file (_PythonApplication1.py_) from the command line.
100
102
101
-
:::image type="content" source="media/tutor-python-2-first-run-program-output.png" alt-text="Screenshot that shows the console window with output for the running program in Visual Studio." border="false" lightbox="media/tutor-python-2-first-run-program-output.png":::
103
+
:::image type="content" source="media/tutor-python-2-first-run-program-output.png" alt-text="Screenshot that shows the console window with output for the running program in Visual Studio." lightbox="media/tutor-python-2-first-run-program-output.png":::
102
104
103
105
1. To close the console window, select any key. You return to the Visual Studio editor.
104
106
@@ -112,7 +114,7 @@ Follow these steps to explore more Intellisense completion features:
112
114
113
115
1. Start to enter the `import sys` statement. When you start to enter `sys`, Visual Studio shows a list of possible modules for the `import` function:
114
116
115
-
:::image type="content" source="media/tutor-python-2-intellisense-import-sys-completion.png" alt-text="Screenshot that shows how IntelliSense displays the available modules for an import statement in the editor in Visual Studio." border="false" lightbox="media/tutor-python-2-intellisense-import-sys-completion.png":::
117
+
:::image type="content" source="media/tutor-python-2-intellisense-import-sys-completion.png" alt-text="Screenshot that shows how IntelliSense displays the available modules for an import statement in the editor in Visual Studio." lightbox="media/tutor-python-2-intellisense-import-sys-completion.png":::
116
118
117
119
You can scroll through the list to see the full set of available modules.
118
120
@@ -126,7 +128,7 @@ Follow these steps to explore more Intellisense completion features:
126
128
127
129
1. Continue the statement by adding a space followed by the `import` function name. Visual Studio shows the list of possible module members for this use of the `import` function:
128
130
129
-
:::image type="content" source="media/tutor-python-2-intellisense-import-members-completion.png" alt-text="Screenshot that shows how IntelliSense displays the available module members for the `import` function in the editor in Visual Studio" border="false" lightbox="media/tutor-python-2-intellisense-import-members-completion.png":::
131
+
:::image type="content" source="media/tutor-python-2-intellisense-import-members-completion.png" alt-text="Screenshot that shows how IntelliSense displays the available module members for the import function in the editor in Visual Studio." lightbox="media/tutor-python-2-intellisense-import-members-completion.png":::
130
132
131
133
1. Finish the statement by using the Intellisense completion options to add the `cos` and `radians` members.
0 commit comments