Tutorial: Work with Python in Visual Studio
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Python is a popular programming language that is reliable, flexible, easy to learn, and free to use on all operating systems. Python is supported by both a strong developer community and many, free libraries. 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. This tutorial guides you through the following steps:
- Step 0: Installation
- Step 1: Create a Python project (this article)
- Step 2: Write and run code to see Visual Studio IntelliSense at work
- Step 3: Create more code in the Interactive REPL window
- Step 4: Run the completed program in the Visual Studio debugger
- Step 5: Install packages and manage Python environments
- Step 6: Work with Git
Prerequisites
- Visual Studio 2017 with the Python workload installed. For instructions, see Work with Python in Visual Studio - Step 0.
You can also use an earlier version of Visual Studio with the Python Tools for Visual Studio installed. See Install Python support in Visual Studio.
Step 1: Create a new Python project
A project is how Visual Studio manages all the files that come together to produce a single application. Application files include source code, resources, and configurations. A project formalizes and maintains the relationships among all the project's files. The project also manages external resources that are shared between multiple projects. A project allows your application to effortlessly expand and grow. Using projects is much easier than manually managing relationships in unplanned folders, scripts, text files, and your memory.
This tutorial begins with a simple project containing a single, empty code file.