Setting Up Python on Your Mac
macOS ships with a legacy Python 2.7 for internal use — never use it for your own code. Follow these four steps to install a proper, modern Python environment. Takes about 10 minutes.
Open Terminal
Press ⌘Space, type Terminal, press ↩. Or find it in Applications → Utilities → Terminal. This is where you run all Python commands.
Xcode Tools
These are Apple's free developer command-line tools — required by Homebrew and pyenv. Run the command in the terminal below. A dialog will appear; click Install.
Install Homebrew
Homebrew is the standard package manager for Mac. It lets you install Python, Git, and thousands of developer tools with a single command from brew.sh.
Install Python
Use pyenv to manage Python versions (strongly recommended over installing Python directly). This lets you switch between versions and keeps your system Python untouched.
arch -x86_64 brew install ... for some packages. The steps above work natively on ARM — no Rosetta needed for Python.
sudo pip install on a Mac. It modifies the system Python and can break macOS tools. Always use a virtual environment (python -m venv .venv) and activate it first.
Essential Terminal Commands
| Command | What it does |
|---|---|
| pwd | Print working directory — shows where you are |
| ls | List files in current directory |
| cd ~/PythonProjects | Change to your projects folder |
| mkdir myapp | Create a new directory |
| python script.py | Run a Python script |
| python | Open the interactive Python REPL |
| pip install requests | Install a package |
| pip list | Show installed packages |
| ⌃ C | Stop a running program |
| ⌃ D | Exit the Python REPL |