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/includes/project-from-existing.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,19 +17,49 @@ Follow these steps to create a project from existing files.
17
17
18
18
1. In the **Create New Project from Existing Python Code** wizard, set the **Folder path** to your existing code, set a **Filter** for file types, and specify any **Search paths** that your project requires, then select **Next**. If you don't know the search paths, leave the field blank.
19
19
20
+
::: moniker range="visualstudio"
21
+
22
+
:::image type="content" source="../media/visualstudio/projects-from-existing-1.png" alt-text="Screenshot of a New Project creation from Existing Code, including choosing the folder path, file type filters, and search paths in Visual Studio." lightbox="../media/visualstudio/projects-from-existing-1.png":::
23
+
24
+
::: moniker-end
25
+
26
+
::: moniker range="vs-2022"
27
+
20
28
:::image type="content" source="../media/projects-from-existing-1.png" alt-text="Screenshot of a New Project creation from Existing Code, including choosing the folder path, file type filters, and search paths." lightbox="../media/projects-from-existing-1.png":::
21
29
30
+
::: moniker-end
31
+
22
32
1. On the next page, select the **Startup file** for your project. Visual Studio selects the default global Python interpreter and version. You can change the environment by using the dropdown menu. When you're ready, select **Next**.
23
33
24
34
> [!NOTE]
25
35
> The dialog shows only files in the root folder. If the file you want is in a subfolder, leave the startup file blank. You can set the startup file in **Solution Explorer**, as described in a later step.
26
36
37
+
::: moniker range="visualstudio"
38
+
39
+
:::image type="content" source="../media/visualstudio/projects-from-existing-2.png" alt-text="Screenshot of New Project Creation from Existing Code window, including choosing the startup file and Python environment in Visual Studio." lightbox="../media/visualstudio/projects-from-existing-2.png":::
40
+
41
+
::: moniker-end
42
+
43
+
::: moniker range="vs-2022"
44
+
27
45
:::image type="content" source="../media/projects-from-existing-2.png" alt-text="Screenshot of New Project Creation from Existing Code window, including choosing the startup file and Python environment." lightbox="../media/projects-from-existing-2.png":::
28
46
47
+
::: moniker-end
48
+
29
49
1. Select the location to store the project file (a _.pyproj_ file on disk). If applicable, you can also include autodetection of virtual environments and customize the project for different web frameworks. If you're unsure of these options, leave the fields set to the defaults.
30
50
51
+
::: moniker range="visualstudio"
52
+
53
+
:::image type="content" source="../media/visualstudio/projects-from-existing-3.png" alt-text="Screenshot of a New Project creation from Existing Code window, including the location for the project file and other optional settings in Visual Studio." lightbox="../media/visualstudio/projects-from-existing-3.png":::
54
+
55
+
::: moniker-end
56
+
57
+
::: moniker range="vs-2022"
58
+
31
59
:::image type="content" source="../media/projects-from-existing-3.png" alt-text="Screenshot of a New Project creation from Existing Code window, including the location for the project file and other optional settings." lightbox="../media/projects-from-existing-3.png" :::
32
60
61
+
::: moniker-end
62
+
33
63
1. Select **Finish**.
34
64
35
65
Visual Studio creates the project and opens it in **Solution Explorer**. If you want to move the _.pyproj_ file to a different location, select the file in **Solution Explorer**, and then select **File** > **Save As** on the toolbar. This action updates file references in the project, but it doesn't move any code files.
Copy file name to clipboardExpand all lines: docs/python/managing-python-projects-in-visual-studio.md
+57-7Lines changed: 57 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Manage Python application projects
2
+
title: Manage Python Application Projects
3
3
description: Explore how projects in Visual Studio manage dependencies between files and the complexity of relationships in an application.
4
-
ms.date: 04/18/2024
4
+
ms.date: 06/01/2026
5
5
ms.topic: how-to
6
6
author: Devdiv-VR
7
7
ms.author: vedhar
@@ -15,7 +15,17 @@ ms.subservice: python
15
15
16
16
Python applications are typically defined by using only folders and files. This structure can become complex as applications grow and perhaps involve autogenerated files, JavaScript for web applications, and so on. A [Visual Studio project](../ide/solutions-and-projects-in-visual-studio.md#projects) can help you manage the complexity. The project (a `.pyproj` file) identifies all the source and content files associated with your project. It contains build information for each file, maintains the information to integrate with source-control systems, and helps you organize your application into logical components.
17
17
18
-
:::image type="content" source="media/projects-solution-explorer.png" alt-text="Screenshot that shows a Python project open in Solution Explorer in Visual Studio." lightbox="media/projects-solution-explorer.png":::
18
+
::: moniker range="visualstudio"
19
+
20
+
:::image type="content" source="media/visualstudio/projects-solution-explorer.png" alt-text="Screenshot that shows a Python project open in Solution Explorer in Visual Studio." lightbox="media/visualstudio/projects-solution-explorer.png":::
21
+
22
+
::: moniker-end
23
+
24
+
::: moniker range="vs-2022"
25
+
26
+
:::image type="content" source="media/projects-solution-explorer.png" alt-text="Screenshot that shows a Python project open in Solution Explorer." lightbox="media/projects-solution-explorer.png":::
27
+
28
+
::: moniker-end
19
29
20
30
Projects are always managed within a [Visual Studio solution](../ide/solutions-and-projects-in-visual-studio.md#solutions). A solution can contain any number of projects that might reference one another, such as a Python project that references a C++ project that implements an extension module. With this relationship, Visual Studio automatically builds the C++ project (if necessary) when you start debugging the Python project. For more information, see [Solutions and projects in Visual Studio](../ide/solutions-and-projects-in-visual-studio.md).
21
31
@@ -53,17 +63,47 @@ If you remove the selected startup file from a project and don't select an alter
53
63
54
64
A new project is always associated with the default global Python environment. To associate the project with a different environment (including virtual environments), right-click the **Python Environments** node in the project. Select **Add Environment** and then select the environments you want. You can also use the environments drop-down control on the toolbar to select an environment or add another environment to the project.
55
65
56
-
:::image type="content" source="media/vs-2022/environments-toolbar-2022.png" alt-text="Screenshot that shows the Add Environment command on the Python toolbar in Visual Studio.":::
66
+
::: moniker range="visualstudio"
67
+
68
+
:::image type="content" source="media/visualstudio/environments-toolbar.png" alt-text="Screenshot that shows the Add Environment command in Visual Studio.":::
69
+
70
+
::: moniker-end
71
+
72
+
::: moniker range="vs-2022"
73
+
74
+
:::image type="content" source="media/vs-2022/environments-toolbar-2022.png" alt-text="Screenshot that shows the Add Environment command on the Python toolbar.":::
75
+
76
+
::: moniker-end
57
77
58
78
To change the active environment, right-click the desired environment in **Solution Explorer** and select **Activate Environment** as shown in the following image. For more information, see [Select an environment for a project](selecting-a-python-environment-for-a-project.md).
59
79
60
-
:::image type="content" source="media/vs-2022/projects-activate-environment-2022.png" alt-text="Screenshot that shows how to activate an environment for a Python project in Visual Studio." lightbox="media/vs-2022/projects-activate-environment-2022.png":::
80
+
::: moniker range="visualstudio"
81
+
82
+
:::image type="content" source="media/visualstudio/projects-activate-environment.png" alt-text="Screenshot that shows how to activate an environment for a Python project in Visual Studio." lightbox="media/visualstudio/projects-activate-environment.png":::
83
+
84
+
::: moniker-end
85
+
86
+
::: moniker range="vs-2022"
87
+
88
+
:::image type="content" source="media/vs-2022/projects-activate-environment-2022.png" alt-text="Screenshot that shows how to activate an environment for a Python project." lightbox="media/vs-2022/projects-activate-environment-2022.png":::
89
+
90
+
::: moniker-end
61
91
62
92
## Project templates
63
93
64
94
Visual Studio gives you many ways to set up a Python project, either from scratch or from existing code. To use a template, select **File** > **New** > **Project** or right-click the solution in **Solution Explorer** and select **Add** > **New Project**. In the **new project** dialog, you can see Python-specific templates by searching on *Python* or by selecting the **Language** > **Python** node:
65
95
66
-
:::image type="content" source="media/projects-new-project-dialog.png" alt-text="Screenshot that shows the new project dialog with available Python templates in Visual Studio." lightbox="media/projects-new-project-dialog.png":::
96
+
::: moniker range="visualstudio"
97
+
98
+
:::image type="content" source="media/visualstudio/projects-new-project-dialog.png" alt-text="Screenshot that shows the new project dialog with available Python templates in Visual Studio." lightbox="media/visualstudio/projects-new-project-dialog.png":::
99
+
100
+
::: moniker-end
101
+
102
+
::: moniker range="vs-2022"
103
+
104
+
:::image type="content" source="media/projects-new-project-dialog.png" alt-text="Screenshot that shows the new project dialog with available Python templates." lightbox="media/projects-new-project-dialog.png":::
105
+
106
+
::: moniker-end
67
107
68
108
::: moniker range=">=vs-2022"
69
109
@@ -120,7 +160,17 @@ Linked files can't be renamed.
120
160
121
161
Visual Studio projects support adding references to projects and extensions, which appear under the **References** node in **Solution Explorer**:
122
162
123
-
:::image type="content" source="media/projects-extension-references.png" alt-text="Screenshot that shows how to Add an extension reference in Python projects in Visual Studio." lightbox="media/projects-extension-references.png":::
163
+
::: moniker range="visualstudio"
164
+
165
+
:::image type="content" source="media/visualstudio/projects-extension-references.png" alt-text="Screenshot that shows how to Add an extension reference in Python projects in Visual Studio." lightbox="media/visualstudio/projects-extension-references.png":::
166
+
167
+
::: moniker-end
168
+
169
+
::: moniker range="vs-2022"
170
+
171
+
:::image type="content" source="media/projects-extension-references.png" alt-text="Screenshot that shows how to Add an extension reference in Python projects." lightbox="media/projects-extension-references.png":::
172
+
173
+
::: moniker-end
124
174
125
175
Extension references typically indicate dependencies between projects and are used to provide IntelliSense at design time or linking at compile time. Python projects use references in a similar fashion, but due to the dynamic nature of Python they're primarily used at design time to provide improved IntelliSense. They can also be used for deployment to Microsoft Azure to install other dependencies.
0 commit comments