Installing Python
First you need to have a Python environment.
Visit the official Python website at python.org for the most up-to-date installation instructions. This guide contains general ways to get a Python environment set up.
Install on your host machine
The most basic way to get a Python environment set up is to install it on your host machine. Go to the official Python website and follow their guide to getting started.
Many OS installs already have Python installed. To check, open a command line terminal and type:
python3 --version
or
python --version
On macOS and Linux, python3 is commonly used. On Windows, python is typically the command.
Windows users: During installation, make sure to check “Add Python to PATH” before clicking “install”
If you receive a response with a Python version you already have Python installed.
Use a Dev Container
You can use a Dev Container to spin up a Python environment. A Dev Container is useful if you do not want to modify your host system. With a Dev Container you can run a containerized environment for Python.
The most common setup uses VSCode with a Dev Container run by Docker or Podman.
Why Dev Containers?
Dev Containers are useful when
- You want consistent environments across a team
- You don’t want to modify your system or your system’s Python
- You are working on multiple projects with different dependencies
Install required software
- Install Docker or Docker Desktop
- Install VSCode
- Install the VSCode extension Dev Containers
Create the Dev Container
-
Using VSCode open the folder where you want to place your project files
# cd into your source folder mkdir my-python-app cd my-python-app code . - Open the
Command PalettetypicallyCtrl+Shift+P - Start typing
Dev Containers: Add Dev Containers Configuration Files... - Select
Add configuration to workspace- This will create a
.devcontainerfolder and allow you to include your Dev Container configuration in source control
- This will create a
- Select a Dev Container
Python 3bydevcontainersis a basic container that can be used - Select the default version it offers (for example, 3.14 or newer)
- You can skip “Select additional features to install”
- You can skip the step to add dependabot configuration or you can add it if you are using GitHub and want to have dependabot configuration set up.
- VSCode may ask for permission to access files. You must allow it to access files.
- You should now have a
.devcontainer/devcontainer.jsonin your folder. If you opted to add dependabot configuration you should also see that file. - VSCode should prompt you with a message “Folder contains a Dev Container configuration file. Reopen folder to develop in a container” select “Reopen in Container” to open your folder in the Dev Container.
- Alternatively, if you are not prompted, click on the
><in the bottom left of the VSCode window and select “Reopen in Container”
- Alternatively, if you are not prompted, click on the
- VSCode will then build the container and reopen your folder in the container. This may take some minutes. Click on “(show log)” to check on progress.
- Once VSCode completes building the container and reopens your folder in the container open the VSCode Terminal and type
python --version
which python
- You should see output similar to
vscode ➜ /workspaces/my-python-app $ python --version
Python 3.14.2
vscode ➜ /workspaces/my-python-app $ which python
/usr/local/bin/python
vscode ➜ /workspaces/my-python-app $
- When you close VSCode and reopen your project folder later choose to open it in the container.