Home / Setup

Install Python, step by step

About 10 minutes on Windows, macOS or Linux. Every step shows the exact command to type and what you should see — plus fixes for the errors people hit most often.

1

Download & install Python

Pick your operating system. Two routes each: the official installer (GUI) or a one-line CLI command.

Option A — installer (easiest):

  • Open python.org/downloads and click Download Python 3.x.x (the big yellow button).
  • Run the downloaded python-3.x.x-amd64.exe.
  • Critical: tick “Add python.exe to PATH” at the bottom of the installer window before clicking Install Now. Skipping this causes 90% of “python is not recognized” problems.
  • Click Install Now, wait ~1 minute, then Close.

Option B — one command (winget): Windows 10/11 ships the winget package manager. Open PowerShell and run:

PowerShell
winget install --id Python.Python.3.13 -e

If several versions exist, list them first with winget search Python.Python. Close and reopen PowerShell after installing.

Option A — official installer: download the macOS 64-bit universal2 installer from python.org/downloads, open the .pkg file and follow the wizard (Continue → Install).

Option B — Homebrew (one command): if you have Homebrew installed, open Terminal and run:

Terminal
brew install python@3.13
On macOS the command is python3 (not python) — Apple reserves python for its legacy stub. This is normal and covered in step 2.

Most Linux distributions already include Python 3. If not (or you want the newest), use your package manager in the Terminal:

Ubuntu / Debian
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
Fedora
sudo dnf install -y python3 python3-pip
Arch
sudo pacman -S python python-pip
2

Verify the installation

Open a fresh terminal and confirm Python and pip both answer.

Windows — PowerShell or CMD
python --version
py --version
python -m pip --version
macOS / Linux — Terminal
python3 --version
python3 -m pip --version

Expected output (versions may differ, the shape should match):

Result
Python 3.13.1
pip 25.0.1 from C:\...\Lib\site-packages\pip (python 3.13)
If both commands print a version, you are done installing. Skip to step 4 — or step 3 if you also want an editor. If a command failed, jump to Troubleshooting.
3

Install a code editor (recommended)

Any text editor works, but a proper editor gives you autocomplete, linting and one-key running.

Visual Studio Code — the most popular free option:

  • Download it from code.visualstudio.com (or winget install Microsoft.VisualStudioCode / brew install --cask visual-studio-code).
  • Open it and install the Python extension (publisher: Microsoft) — it bundles Pylance, the debugger, and a test runner.
  • Open your project folder: File → Open Folder, or from the terminal: code .
  • Run code instantly: open a .py file and press the ▶ Run button (top right) or Ctrl+F5.
Alternatives: PyCharm Community (full IDE), Thonny (beginner-friendly, great for first steps), or Sublime Text (fast and light). Even Notepad works — the interpreter does not care.
4

Create your first project — all CLI

Folders, a virtual environment and a hello-world script, using nothing but terminal commands.

Windows — PowerShell
mkdir hello-python
cd hello-python

# create an isolated environment for this project
python -m venv .venv

# activate it (PowerShell)
.venv\Scripts\Activate.ps1

# if PowerShell blocks the script, allow it once:
# Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Windows — CMD
mkdir hello-python
cd hello-python
python -m venv .venv
.venv\Scripts\activate.bat
macOS / Linux
mkdir hello-python
cd hello-python
python3 -m venv .venv
source .venv/bin/activate

When the environment is active your prompt gets a (.venv) prefix. Now create the program — type this in your editor, or entirely from the terminal:

Create hello.py — Windows PowerShell
@'
def greet(name: str) -> str:
    return f"Hello, {name}! Welcome to Python."

for person in ["Ada", "Linus", "Guido"]:
    print(greet(person))

print("Python version:")
import sys
print(sys.version)
'@ | Out-File -Encoding utf8 hello.py
Create hello.py — macOS / Linux
cat > hello.py << 'EOF'
def greet(name: str) -> str:
    return f"Hello, {name}! Welcome to Python."

for person in ["Ada", "Linus", "Guido"]:
    print(greet(person))

print("Python version:")
import sys
print(sys.version)
EOF
hello.py
def greet(name: str) -> str:
    return f"Hello, {name}! Welcome to Python."

for person in ["Ada", "Linus", "Guido"]:
    print(greet(person))

print("Python version:")
import sys
print(sys.version)

Run it:

Run
python hello.py
# macOS / Linux: python3 hello.py
Output
Hello, Ada! Welcome to Python.
Hello, Linus! Welcome to Python.
Hello, Guido! Welcome to Python.
Python version:
3.13.1 (tags/v3.13.1:0671451, ...) [...]
Congratulations — you are running Python. From here, work through the curriculum and type every example yourself; typing the code is how it sticks.
5

Install packages with pip

pip is Python's package manager — 500,000+ libraries on PyPI, one command away.

Essential pip commands
pip install requests          # install one package
pip install requests==2.32.3  # pin an exact version
pip list                      # what's installed
pip show requests             # details about one package
pip uninstall -y requests     # remove it

Real projects freeze their dependencies so anyone can rebuild the environment:

Reproducible environments
pip freeze > requirements.txt        # save current state
pip install -r requirements.txt      # rebuild it elsewhere
Try it right now
pip install requests
python -c "import requests; r = requests.get('https://httpbin.org/get'); print(r.status_code)"
Always work inside a virtual environment (venv). It keeps each project's packages separate and avoids the error: externally-managed-environment message that newer Ubuntu/Debian/macOS python3 prints when pip is used system-wide.
6

Essential terminal commands

The small set you will use every day. Windows column shows PowerShell equivalents.

Task Windows (PowerShell) macOS / Linux
Show current folder Get-ChildItem / dir / ls ls
Change folder cd hello-python cd hello-python
Make a folder New-Item -ItemType Directory demo / mkdir demo mkdir demo
Run a script python hello.py python3 hello.py
Start Python shell python python3
Run a module python -m pip install x python3 -m pip install x
Exit the shell exit() or Ctrl+Z then Enter (Windows) / Ctrl+D (macOS/Linux)
Clear screen Clear-Host / cls clear / Ctrl+L
Stop a running script Ctrl+C
Help for any command python --help, pip help, or append --help to most tools
7

Run this website locally (optional)

Already know Python? Use it to serve this site — the same command works forever, no Node required.

Serve the folder with Python
cd pymastery          # the folder that contains index.html
python -m http.server 8099
# macOS / Linux: python3 -m http.server 8099

Open http://localhost:8099 in your browser. Stop the server with Ctrl+C.

The playground and challenges download the Python runtime from a CDN, so your machine needs internet the first time. You don't need Python installed to use them — it runs inside the browser. When you're ready, put the site online with the Vercel deploy guide.
8

Setup checklist

Tick items as you go — saved in your browser, nothing is uploaded.

9

Troubleshooting

The errors almost everyone hits once — and the exact fix for each.

Symptom Cause Fix
'python' is not recognized… Python wasn't added to the PATH Re-run the installer → Modify → tick Add python.exe to PATH. Or use the py launcher: py --version
Typing python opens the Microsoft Store Windows app-execution alias intercepts the command Settings → Apps → Advanced app settings → App execution aliases → turn off the two python.exe (App Installer) entries. Then use python or py
python3: command not found Only python exists, or PATH is stale Try python --version. On macOS install via the python.org installer or brew install python3
pip: command not found pip not installed / not on PATH Call it through the interpreter: python -m pip --version. If missing: python -m ensurepip --upgrade
error: externally-managed-environment System Python (PEP 668) refuses global installs Correct fix: create and activate a venv (python -m venv .venv), then pip install inside it
Set-ExecutionPolicy error activating venv PowerShell blocks unsigned scripts Run once: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned, then re-activate — or use CMD with .venv\Scripts\activate.bat
macOS: xcrun: error: invalid active developer path Command Line Tools missing after an OS update Run xcode-select --install and retry
Permission denied installing packages Writing to a system-owned location Activate a project venv first and install there — never install packages system-wide
Wrong output / old behavior after upgrading Python Multiple versions installed; PATH picks the old one Check where python (Windows) or which -a python3 (macOS/Linux); adjust PATH order or rely on the venv
Still stuck? The in-browser playground runs real Python with zero setup, so you can keep learning while you sort out the local install. The official docs also maintain a full installation guide.