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.
Pick your operating system. Two routes each: the official installer (GUI) or a one-line CLI command.
Option A — installer (easiest):
python-3.x.x-amd64.exe.Option B — one command (winget): Windows 10/11 ships the winget package manager. Open
PowerShell and run:
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:
brew install python@3.13
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:
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
sudo dnf install -y python3 python3-pip
sudo pacman -S python python-pip
Open a fresh terminal and confirm Python and pip both answer.
python --version
py --version
python -m pip --version
python3 --version
python3 -m pip --version
Expected output (versions may differ, the shape should match):
Python 3.13.1
pip 25.0.1 from C:\...\Lib\site-packages\pip (python 3.13)
Any text editor works, but a proper editor gives you autocomplete, linting and one-key running.
Visual Studio Code — the most popular free option:
winget install Microsoft.VisualStudioCode /
brew install --cask visual-studio-code).code ..py file and press the ▶ Run button (top right) or Ctrl+F5.Folders, a virtual environment and a hello-world script, using nothing but terminal commands.
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
mkdir hello-python
cd hello-python
python -m venv .venv
.venv\Scripts\activate.bat
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:
@'
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
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
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:
python hello.py
# macOS / Linux: python3 hello.py
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, ...) [...]
pip is Python's package manager — 500,000+ libraries on PyPI, one command away.
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:
pip freeze > requirements.txt # save current state
pip install -r requirements.txt # rebuild it elsewhere
pip install requests
python -c "import requests; r = requests.get('https://httpbin.org/get'); print(r.status_code)"
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.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 |
|
Already know Python? Use it to serve this site — the same command works forever, no Node required.
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.
Tick items as you go — saved in your browser, nothing is uploaded.
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 |