Codectionary / Developer documentation / Python

Connect the editor, Microsoft’s Python extension and a Python interpreter, then run a saved script.

Install the three pieces

Instructions checked 18 October 2026 against the official documentation linked below. Menu labels may differ between releases; verify the selected interpreter rather than relying only on its display name.

VS Code is an editor, not the Python interpreter. This guide follows the current VS Code Python extension workflow; a specific VS Code patch version is not required.

  1. Install VS Code from its official download page for your operating system.
  2. Install Python using your OS guide if it is not already available.
  3. Open VS Code’s Extensions view and install Python by Microsoft (ms-python.python). The extension does not include the interpreter.

Open a folder and choose Python

Use File → Open Folder to open python-practice. Create .venv using the environment guide if you will install packages. Open the Command Palette (Ctrl+Shift+P, or Cmd+Shift+P on macOS) and run Python: Select Interpreter. Choose the project’s .venv, or your installed Python for a simple first script.

If it is not listed, use the interpreter-path option to locate its executable. Create a new integrated terminal after selection; an old terminal may still have a different environment. Only trust workspaces whose contents you understand.

Create and run hello.py

In the Explorer, create hello.py, enter the first-program example below, and save. Use Run Python File in Terminal from the Python run control. The integrated terminal should show Hello, Python!; this is separate from the editor’s Problems panel.

For an interpreter check, temporarily run the diagnostic below in the same file. Version and path vary by installation; the path should match the interpreter you selected.

Python diagnostic — save in a .py file

import sys
print(sys.version)
print(sys.executable)

Common problems

No interpreter found: install Python, restart VS Code, then select its executable. An extension alone cannot execute Python.

ModuleNotFoundError: compare the run’s sys.executable with the environment receiving python -m pip install. A package installed globally may be absent from .venv.

The wrong output or file runs: save the active file and use the Python extension’s Run Python File in Terminal command. Other extensions can supply different run buttons. A script named json.py can hide the standard library module, so rename it.

Syntax

print("Hello, Python!")

Examples

Your first Python program

Save as hello.py in your project folder. Expected output: Hello, Python!

print("Hello, Python!")
  1. print is a built-in function that writes to the output stream.
  2. The quoted text is a string. The quotes are not printed.
  3. Parentheses pass that string to print. No extra package is required.

Best practices

  • Save your work before running it, and check the output after each small change.
  • Keep your learning project in its own folder. Do not name files after standard modules such as random.py or json.py.

Runtime & versions

Python interpreter. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Python language reference

Specifications & further reading