Convert Figma logo to code with AI

microsoft logovscode-python

Python extension for Visual Studio Code

4,310
1,180
4,310
521

Top Related Projects

An implementation of the Language Server Protocol for Python

Documentation and issues for Pylance

13,105

Static Type Checker for Python

18,182

Optional static typing for Python

63,003

The Python programming language

11,654

Jupyter Interactive Notebook

Quick Overview

The microsoft/vscode-python repository is the official Python extension for Visual Studio Code. It provides rich support for the Python language, including features like IntelliSense, linting, debugging, code navigation, code formatting, refactoring, unit tests, and more.

Pros

  • Comprehensive Python development environment within VS Code
  • Regular updates and active maintenance by Microsoft
  • Extensive customization options and settings
  • Seamless integration with popular Python tools and frameworks

Cons

  • Can be resource-intensive, especially on older hardware
  • Occasional conflicts with other extensions or Python environments
  • Some advanced features may require additional setup or configuration
  • Learning curve for users new to VS Code or complex Python development

Getting Started

  1. Install Visual Studio Code from https://code.visualstudio.com/
  2. Open VS Code and navigate to the Extensions view (Ctrl+Shift+X)
  3. Search for "Python" and install the official Python extension by Microsoft
  4. Open a Python file or project in VS Code
  5. Select a Python interpreter by clicking on the Python version in the bottom status bar
  6. Start coding with IntelliSense, linting, and debugging features available

For more detailed instructions and advanced features, refer to the official documentation at https://code.visualstudio.com/docs/languages/python

Competitor Comparisons

An implementation of the Language Server Protocol for Python

Pros of python-language-server

  • Lightweight and focused solely on language server functionality
  • Can be integrated with various editors and IDEs, not limited to VS Code
  • Provides a standardized Language Server Protocol (LSP) implementation

Cons of python-language-server

  • Less actively maintained compared to vscode-python
  • Fewer features and extensions beyond core language server capabilities
  • May require additional setup and configuration for full functionality

Code Comparison

vscode-python:

from vscode import *

class PythonExtension:
    def __init__(self):
        self.activate()

    def activate(self):
        # Extension-specific activation code

python-language-server:

from pyls import hookimpl

@hookimpl
def pyls_initialize(config, workspace):
    # Language server initialization code

The code snippets demonstrate the different focus areas of each project. vscode-python is tailored for VS Code integration, while python-language-server provides a more generic language server implementation that can be used with various editors supporting the Language Server Protocol.

Documentation and issues for Pylance

Pros of Pylance-release

  • Faster and more accurate IntelliSense and type checking
  • Built on Microsoft's Pyright type checker for improved performance
  • Offers advanced features like auto-imports and signature help

Cons of Pylance-release

  • Smaller community and fewer contributors compared to vscode-python
  • More focused on language server functionality, less comprehensive than vscode-python

Code Comparison

vscode-python:

from jedi import Script

script = Script(source, path=path)
completions = script.complete(line, column)

Pylance-release:

from pyright import LanguageServerProtocol

lsp = LanguageServerProtocol()
completions = lsp.getCompletions(document, position)

Summary

Pylance-release offers improved performance and advanced language features, leveraging Microsoft's Pyright type checker. However, it has a smaller community and focuses primarily on language server functionality. vscode-python provides a more comprehensive Python development experience with broader community support. The code comparison illustrates the different approaches to code completion, with Pylance using a more modern Language Server Protocol implementation.

13,105

Static Type Checker for Python

Pros of Pyright

  • Faster type checking and analysis compared to the Python extension
  • More accurate and comprehensive static type checking
  • Can be used as a standalone tool outside of VS Code

Cons of Pyright

  • Focused solely on type checking, lacking other features of the Python extension
  • May have a steeper learning curve for users new to static typing
  • Requires separate installation and configuration from the main Python extension

Code Comparison

Pyright configuration (pyright.json):

{
  "include": ["src"],
  "exclude": ["**/node_modules", "**/__pycache__"],
  "strict": ["src/core"]
}

VS Code Python extension settings (settings.json):

{
  "python.linting.pylintEnabled": true,
  "python.formatting.provider": "black",
  "python.analysis.typeCheckingMode": "basic"
}

The Pyright configuration focuses on type checking settings, while the VS Code Python extension settings cover a broader range of Python development features.

18,182

Optional static typing for Python

Pros of mypy

  • Focused specifically on static type checking for Python
  • Can be integrated into various development environments and CI/CD pipelines
  • Provides more advanced type inference and checking capabilities

Cons of mypy

  • Limited to type checking functionality only
  • Requires separate installation and configuration
  • May have a steeper learning curve for beginners

Code Comparison

mypy:

from typing import List

def greet(names: List[str]) -> None:
    for name in names:
        print(f"Hello, {name}!")

vscode-python (type checking with Pylance):

def greet(names: list[str]) -> None:
    for name in names:
        print(f"Hello, {name}!")

Summary

While mypy excels in static type checking for Python, vscode-python offers a more comprehensive IDE experience with integrated type checking through Pylance. mypy provides more advanced type checking capabilities but requires separate setup, whereas vscode-python offers a more user-friendly, all-in-one solution for Python development within Visual Studio Code.

63,003

The Python programming language

Pros of cpython

  • Core implementation of the Python programming language
  • Provides the foundation for all Python development and execution
  • Extensive standard library with built-in modules and functions

Cons of cpython

  • Steeper learning curve for contributors due to its complexity
  • Less focused on IDE-specific features and extensions
  • Slower development cycle for new features compared to vscode-python

Code Comparison

cpython (Python interpreter):

def hello_world():
    print("Hello, World!")

hello_world()

vscode-python (Extension functionality):

export function activate(context: vscode.ExtensionContext) {
    console.log('Python extension activated');
    // Extension-specific code
}

The cpython example shows a simple Python function, while the vscode-python snippet demonstrates extension activation in TypeScript, highlighting the different focus areas of these projects.

cpython is the reference implementation of Python, providing the core language and standard library. vscode-python, on the other hand, is an extension for Visual Studio Code that enhances the Python development experience within the IDE. While cpython is essential for running Python code, vscode-python offers features like IntelliSense, debugging, and linting specifically tailored for VS Code users.

11,654

Jupyter Interactive Notebook

Pros of Notebook

  • Web-based interface accessible from any browser
  • Interactive cell-based execution model
  • Rich output display including visualizations and multimedia

Cons of Notebook

  • Less integrated development environment features
  • Limited version control and collaboration capabilities
  • Can lead to non-linear code execution and reproducibility issues

Code Comparison

Notebook:

%%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.show()

VSCode Python:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.show()

The main difference is the %%matplotlib inline magic command in Notebook, which is not needed in VSCode as it automatically handles plot display.

Summary

Notebook excels in interactive data exploration and visualization, while VSCode Python offers a more comprehensive development environment. Notebook's cell-based execution model allows for quick experimentation, but can lead to reproducibility issues. VSCode Python provides better integration with version control and debugging tools, making it more suitable for larger projects and professional development workflows.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Python extension for Visual Studio Code

A Visual Studio Code extension with rich support for the Python language (for all actively supported Python versions), providing access points for extensions to seamlessly integrate and offer support for IntelliSense (Pylance), debugging (Python Debugger), formatting, linting, code navigation, refactoring, variable explorer, test explorer, and more!

Support for vscode.dev

The Python extension does offer some support when running on vscode.dev (which includes github.dev). This includes partial IntelliSense for open files in the editor.

Installed extensions

The Python extension will automatically install the following extensions by default to provide the best Python development experience in VS Code:

  • Pylance - to provide performant Python language support
  • Python Debugger - to provide a seamless debug experience with debugpy

These extensions are optional dependencies, meaning the Python extension will remain fully functional if they fail to be installed. Any or all of these extensions can be disabled or uninstalled at the expense of some features. Extensions installed through the marketplace are subject to the Marketplace Terms of Use.

Extensibility

The Python extension provides pluggable access points for extensions that extend various feature areas to further improve your Python development experience. These extensions are all optional and depend on your project configuration and preferences.

If you encounter issues with any of the listed extensions, please file an issue in its corresponding repo.

Quick start

Set up your environment

Jupyter Notebook quick start

The Python extension offers support for Jupyter notebooks via the Jupyter extension to provide you a great Python notebook experience in VS Code.

For more information you can:

Useful commands

Open the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux) and type in one of the following commands:

CommandDescription
Python: Select InterpreterSwitch between Python interpreters, versions, and environments.
Python: Start Terminal REPLStart an interactive Python REPL using the selected interpreter in the VS Code terminal.
Python: Run Python File in TerminalRuns the active Python file in the VS Code terminal. You can also run a Python file by right-clicking on the file and selecting Run Python File in Terminal.
Python: Configure TestsSelect a test framework and configure it to display the Test Explorer.

To see all available Python commands, open the Command Palette and type Python. For Jupyter extension commands, just type Jupyter.

Feature details

Learn more about the rich features of the Python extension:

  • IntelliSense: Edit your code with auto-completion, code navigation, syntax checking and more
  • Linting: Get additional code analysis with Pylint, Flake8 and more
  • Code formatting: Format your code with black, autopep or yapf
  • Debugging: Debug your Python scripts, web apps, remote or multi-threaded processes
  • Testing: Run and debug tests through the Test Explorer with unittest or pytest.
  • Jupyter Notebooks: Create and edit Jupyter Notebooks, add and run code cells, render plots, visualize variables through the variable explorer, visualize dataframes with the data viewer, and more
  • Environments: Automatically activate and switch between virtualenv, venv, pipenv, conda and pyenv environments
  • Refactoring: Restructure your Python code with variable extraction and method extraction. Additionally, there is componentized support to enable additional refactoring, such as import sorting, through extensions including isort and Ruff.

Supported locales

The extension is available in multiple languages: de, en, es, fa, fr, it, ja, ko-kr, nl, pl, pt-br, ru, tr, zh-cn, zh-tw

Questions, issues, feature requests, and contributions

  • If you have a question about how to accomplish something with the extension, please ask on our Discussions page.
  • If you come across a problem with the extension, please file an issue.
  • Contributions are always welcome! Please see our contributing guide for more details.
  • Any and all feedback is appreciated and welcome!
    • If someone has already filed an issue that encompasses your feedback, please leave a 👍/👎 reaction on the issue.
    • Otherwise please start a new discussion.
  • If you're interested in the development of the extension, you can read about our development process.

Data and telemetry

The Microsoft Python Extension for Visual Studio Code collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more. This extension respects the telemetry.enableTelemetry setting which you can learn more about at https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting.