Install Python on Mac + Setup pyenv & Virtual Environments (2026 Guide)

In this tutorial I'll walk you through installing Python on macOS the clean way — using Homebrew and pyenv — and then setting up virtual environments (venv) so your projects stay isolated and reproducible. NOTE: The few commands that use a redirect symbol are in the PINNED COMMENT, since YouTube blocks that character in descriptions. === ALL COMMANDS === 1. INSTALL HOMEBREW Run the official install command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Hom...)" 2. ADD HOMEBREW TO YOUR PATH Apple Silicon users run this: eval "$(/opt/homebrew/bin/brew shellenv)" Intel Mac users run this: eval "$(/usr/local/bin/brew shellenv)" (To make it permanent, add the same line to your ~/.zshrc — see the PINNED COMMENT for the one-line copy-paste version.) Verify the installation: brew --version 3. INSTALL PYENV brew install pyenv Add pyenv to your shell by pasting these into ~/.zshrc: export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv init -)" (Restart your terminal after this step.) 4. INSTALL PYTHON pyenv install 3.11.9 Set it as your global default: pyenv global 3.11.9 Or set it just for one project folder: pyenv local 3.11.9 5. CREATE A VIRTUAL ENVIRONMENT python -m venv venv Activate it: source venv/bin/activate Install packages: pip install pandas numpy 6. SAVE & RESTORE DEPENDENCIES Save and restore commands are in the PINNED COMMENT (they use a redirect symbol). To leave the virtual environment: deactivate If this helped, like and subscribe for more dev tutorials! #Python #macOS #Homebrew #pyenv #coding #programming