Quickstart: Create a Python project from existing code
Once you've installed Python support in Visual Studio, it's easy to bring existing Python code into a Visual Studio project.
The process described here does not move or copy the original source files. If you want to work with a copy, duplicate the folder first.
Launch Visual Studio and select File > New > Project.
In the New Project dialog, search for "Python", select the From Existing Python code template, give the project a name and location, and select OK.
In the wizard that appears, set the 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 what search paths are, leave that field blank.
In the next dialog, select the startup file for your project and select Next. (If desired, select an environment; otherwise accept the defaults.) Note that the dialog shows only files in the root folder; if the file you want is in a subfolder, leave the startup file blank and set it later in Solution Explorer (described below).
Select the location in which to save the project file (which is a .pyproj file on disk). If applicable, you can also include auto-detection of virtual environments and customize the project for different web frameworks. If you're unsure of these options, leave them set to the defaults.
Select Finish and Visual Studio creates the project and opens it in Solution Explorer. If you want to move the .pyproj file elsewhere, select it in Solution Explorer and choose File > Save As. This action updates file references in the project but does not move any code files.
To set a different startup file, locate the file in Solution Explorer, right-click, and select Set as Startup File.
If desired, run the program by pressing Ctrl+F5 or selecting Debug > Start without Debugging.