Install Python and VS Code
Tip
See the Text and images tab for more details!
To write and run Python programs on your own machine, you need two things: the Python interpreter and a code editor. In this unit, you install both.
Install Python
Python doesn't come preinstalled on all machines, so the first step is to download it from the official website.
- Go to python.org/downloads.
- Download the latest stable version for your operating system.
- Run the installer. On Windows, make sure to check Add Python to PATH before clicking Install Now.
Once installed, confirm the installation was successful by opening a terminal and running:
python --version
You should see a version number such as Python 3.12.10.
Note
If you're not sure which terminal to use, you can search for "Terminal" in the Start menu on Windows, or use the built-in Terminal app on macOS and Linux.
Install Visual Studio Code
Visual Studio Code (VS Code) is a free, lightweight code editor from Microsoft that works on Windows, macOS, and Linux. It has excellent Python support through extensions.
- Go to code.visualstudio.com.
- Download and run the installer for your operating system.
- Open VS Code after installation completes.
Install the Python extension
VS Code uses extensions to add language support. The Python extension adds features like syntax highlighting, error detection, and the ability to run Python files directly in the editor.
- In VS Code, open the Extensions panel (Ctrl+Shift+X).
- Search for Python and select the extension published by Microsoft.
- Click Install.
Once installed, VS Code can detect your Python installation and provide intelligent code assistance.