Share via


Welcome to the Visual Studio IDE | Python

Applies to: yesVisual Studio noVisual 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

The Visual Studio integrated development environment is a creative launching pad for Python (and other languages) that you can use to edit, debug, and test code, and then publish an app. An integrated development environment (IDE) is a feature-rich program that can be used for many aspects of software development. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes code completion tools, interactive REPL environments, and other features to ease the software development process.

Visual Studio with a Python project

This image shows Visual Studio with an open Python project and several key tool windows you'll likely use:

  • Solution Explorer (top right) lets you view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

    • Alongside Solution Explorer is Python Environments, where you manage the different Python interpreters that are installed on your computer.
  • The editor window (center), where you'll likely spend a majority of your time, displays file contents. This is where you edit Python code, navigate within your code structure, and set breakpoints during debugging sessions. With Python, you can also select code and press Ctrl+Enter to run that code in an interactive REPL window.

  • The Output window (bottom center) is where Visual Studio sends notifications such as debugging and error messages, warnings, publishing status messages, and more. Each message source has its own tab.

  • Team Explorer (bottom right) lets you track work items and share code with others using version control technologies such as Git and Team Foundation Version Control (TFVC).

Editions

Visual Studio is available for Windows and Mac; however, Python support is available only on Visual Studio for Windows.

There are three editions of Visual Studio on Windows: Community, Professional, and Enterprise. See Compare Visual Studio IDEs to learn about which features are supported in each edition.

Some of the popular features in Visual Studio that help you to be more productive as you develop software include:

  • IntelliSense

    IntelliSense is a term for a set of features that displays information about your code directly in the editor and, in some cases, write small bits of code for you. It's like having basic documentation inline in the editor, which saves you from having to look up type information elsewhere. IntelliSense features vary by language, and the Editing Python code article has details for Python. The following illustration shows how IntelliSense displays a member list for a type:

    Member completion with Visual Studio IntelliSense

  • Refactoring

    By right-clicking on a piece of code and selecting Quick actions and Refactorings, Visual Studio provides you with operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, changing the order of method parameters, and more.

    Refactoring in Visual Studio

  • Linting

    Linting checks for errors and common problems in your Python code, encouraging you with good Python coding patterns.

    PyLint command on context menu for Python projects

  • Search box

    Visual Studio can seem overwhelming at times with so many menus, options, and properties. The search box is a great way to rapidly find what you need in Visual Studio. When you start typing the name of something you're looking for, Visual Studio lists results that take you exactly where you need to go. If you need to add functionality to Visual Studio, for example to add support for an additional programming language, the search box provides results that open Visual Studio Installer to install a workload or individual component.

    Search box in Visual Studio

  • Squiggles and Quick Actions

    Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues enable you to fix problems immediately without waiting for the error to be discovered during build or when you run the program. If you hover over a squiggle, you see additional information about the error. A light bulb may also appear in the left margin with actions, known as Quick Actions, to fix the error.

    Squiggles in Visual Studio

  • Go To and Peek Definition

    The Go To Definition feature takes you directly to the location where a function or type is defined. The Peek Definitions command displays the definition in a window without opening a separate file. The Find All References command also provides a helpful way to discover where any given identifier is both defined and used.

    Code navigation commands

Powerful features for Python

  • Collaborate using Visual Studio

    Visual Studio Live Share enables you to collaboratively edit and debug with others in real time, regardless of what programming language you're using or app types you're building.

  • Python Interactive REPL

    Visual Studio provides an interactive read-evaluate-print loop (REPL) window for each of your Python environments, which improves upon the REPL you get with python.exe on the command line. In the Interactive window you can enter arbitrary Python code and see immediate results.

    Python interactive window

  • Debugging

    Visual Studio provides a comprehensive debugging experience for Python, including attaching to running processes, evaluating expressions in the Watch and Immediate windows, inspecting local variables, breakpoints, step in/out/over statements, Set Next Statement, and more. You can also debug remote Python code running on Linux computers.

    Debugging Python in Visual Studio

  • Interacting with C++

    Many libraries created for Python are written in C++ for optimal performance. Visual Studio provides rich facilities for developing C++ extensions, including mixed-mode debugging.

    Mixed-mode debugging of Python and C++ together

  • Profiling

    When using a CPython-based interpreter, you can evaluate the performance of your Python code within Visual Studio.

    Profiling performance report

  • Unit Testing

    Visual Studio provides integrated support for discovering, running, and debugging unit tests all in the context of the IDE.

    Unit testing showing a failed test status

Next steps

Explore Python in Visual Studio further by following one of the following quickstarts or tutorials:

See also