How to Install Python

What you’ll build or solve

You’ll install Python on your computer and confirm your terminal can run it.

When this approach works best

This approach works best when you:

  • Need Python for a course, a coding project, or a tool that requires Python.
  • Want a clean install on a new computer.
  • Installed Python before but the terminal cannot find it, so you’re installing it again the right way.

Avoid this approach when:

  • Your work or school manages your device and requires IT approval for installs.
  • You’re setting up a production server. Use your server’s deployment process instead of installing by hand.

Prerequisites

  • Internet connection to download the installer
  • Permission to install software on your machine
  • A terminal to verify the install

Step-by-step instructions

1) Download the Python installer from python.org

Go to Python.org.

The page detects your operating system and shows the latest stable version.

On Linux, skip to step 4: python.org only offers source code for Linux.

Click Download Python 3.x.x to get the installer for your platform. On Windows, the main button is Download Python install manager.

If you see multiple download buttons, pick the one that matches your OS (Windows or macOS).

After installation finishes, you can delete the installer file.


2) Install on Windows

Option A (most common): Install with the Python install manager

Run the file you downloaded and select Install (or run winget install 9NQ7512CXL7T -e in a terminal). Then open a new PowerShell window and install the latest Python:

pymanager install default

If it asks to add a folder to PATH, you can accept.

python.org still links a standalone installer below the main button. It’s deprecated and won’t be made for Python 3.16 or later. If you use it, check Add python.exe to PATH on the first screen.

Open a new PowerShell window and verify:

python --version
py -V
python -m pip --version

What to look for:

py comes from the install manager (or the older Python Launcher). If py -V works but python --version does not, see Mistake 1 below.

Option B (alternative): Install with winget

Each minor Python version has its own winget ID. Install the newest Python.Python.3.x ID from the search results (3.14 in the example below).

winget search Python.Python.3
winget install --id Python.Python.3.14 -e

Open a new terminal, then verify:

python --version
python -m pip --version
where.exe python

What to look for:

where.exe python can show multiple entries. The first one is usually what runs when you type python.


3) Install on macOS

Option A (most common): Install with Homebrew

brew update
brew install python

Verify:

python3 --version
python3 -m pip --version
which python3

What to look for:

which python3 often points to /opt/homebrew/bin/python3 (Apple Silicon) or /usr/local/bin/python3 (Intel).

Option B (alternative): Install from python.org

Run the installer from python.org, then verify:

python3 --version
python3 -m pip --version
which python3

If your terminal still points to an older location, PATH order is likely the cause.


4) Install on Linux

Linux installs depend on your distro. Most of the time, install Python using your package manager.

Option A (most common): Use your package manager

Ubuntu/Debian example:

sudo apt update
sudo apt install python3 python3-pip python3-venv

Verify:

python3 --version
python3 -m pip --version
which python3

Option B (alternative): Use pyenv for a newer version

If your distro’s Python is older than what you need, pyenv lets you install a newer version for your user account.

After installing pyenv, install and select a version:

pyenv install 3.15
pyenv global 3.15
python --version
python -m pip --version

If pyenv says 3.15 isn’t a known version, update pyenv first: brew upgrade pyenv (Homebrew), git -C "$(pyenv root)" pull (git install), or pyenv update (pyenv.run installer).

What to look for:

If your shell still runs the old version, restart your terminal or complete the pyenv shell setup.


5) Create a virtual environment for your first project

A virtual environment keeps project packages separate from the system install.

Create a venv in your project folder:

# macOS/Linux
python3 -m venv .venv

# Windows PowerShell
python -m venv .venv

Activate it:

# macOS/Linux
source .venv/bin/activate

# Windows PowerShell
.\.venv\Scripts\Activate.ps1

Upgrade pip inside the venv:

python -m pip install --upgrade pip

What to look for:

Your prompt usually changes when the venv is active, and:

python -c "import sys; print(sys.prefix)"

points to the .venv path.


6) Verify Python and pip work correctly

Run a quick check that Python and pip work and that you’re using the interpreter you expect:

python -c "import sys; print(sys.version); print(sys.executable)"
python -m pip --version

If you’re on macOS/Linux and use python3, run:

python3 -c "import sys; print(sys.version); print(sys.executable)"
python3 -m pip --version

Examples you can copy

Example 1: Windows install from python.org, then verify

python --version
py -V
python -m pip --version
where.exe python

Use this when you want to confirm both PATH and the launcher are set up.

Example 2: macOS Homebrew install and version check

brew install python
python3 --version
which python3
python3 -m pip --version

Use this when you want a Homebrew-managed Python for development.

Example 3: Linux apt install, then create a venv

sudo apt update
sudo apt install python3 python3-pip python3-venv
python3 --version
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip

Use this when you’re starting a new project and want isolated dependencies.


Common mistakes and how to fix them

Mistake 1: Installing Python, but python is “not recognized” on Windows

You install Python, then run:

python --version

and get a “not recognized” error.

Why it happens:

Python was not added to PATH, or a different python.exe is taking precedence.

Fix:

py -V
where.exe python

If py -V works but python does not: with the install manager, open Manage app execution aliases and turn on the Python (default) aliases. With the standalone installer, reinstall and select Add python.exe to PATH. If where.exe python lists a different python.exe first, adjust PATH so the correct folder appears first.


Mistake 2: Installing packages with pip, but imports still fail

You run:

pip install requests

but import requests fails.

Why it happens:

pip installed into a different Python than the one running your code.

Fix: activate your project’s virtual environment (step 5), then run pip through Python. Outside a venv, the distro Python on Debian 12+ and Ubuntu 23.04+ and Homebrew Python 3.12+ block pip installs by default with error: externally-managed-environment (PEP 668).

python -m pip install requests
python -c "import requests; print(requests.__version__)"

If you use python3, do:

python3 -m pip install requests

Troubleshooting

  • If you see python: command not found on macOS/Linux, use python3 instead.
  • If py works but python doesn’t on Windows, follow Mistake 1 above for your installation method.
  • If pip installs to the wrong place, use python -m pip and verify with python -c "import sys; print(sys.executable)" (python3 on macOS/Linux).
  • If you get permission errors or externally-managed-environment on Linux or macOS when installing packages, use a virtual environment instead of installing globally.
  • If you keep seeing an older version, check which executable runs:
python -c "import sys; print(sys.executable)"
python3 -c "import sys; print(sys.executable)"

Quick recap

  • Download the installer from python.org.
  • Install Python using the method that fits your OS.
  • Verify the version and interpreter path in your terminal.
  • Create a virtual environment for projects.
  • Use python -m pip to install packages into the right Python.
  • Recheck PATH or interpreter selection if the version looks wrong.