How to Install Python on Mac (2025 Guide)
In this article
To install and run Python on your Mac, the quickest way is to download the official installer from python.org, run it, and then verify the installation in Terminal. This guide walks you through the whole process, including checking if Python is already installed, using the installer, and running your first script.
What You'll Need
- A Mac running macOS 10.9 or later (most modern Macs qualify).
- An internet connection to download the installer.
- Administrator access to your Mac (you'll need to enter your password during installation).
- About 200 MB of free disk space for the installation.
Step-by-Step
- Check if Python is already installed. Open Terminal (found in Applications > Utilities, or search with Spotlight). Type
python3 --versionand press Enter. If you see something likePython 3.12.4, you already have Python and can skip to step 5. If you seecommand not found, continue with step 2. - Download the installer. Go to python.org/downloads in your web browser. Click the yellow button that says "Download Python 3.x.x" (the exact version number changes over time). This downloads a
.pkgfile to your Downloads folder. - Run the installer. Double-click the downloaded
.pkgfile. A window will appear asking you to install Python. Click "Continue" through the introduction and license agreement, then click "Install". You may need to enter your Mac's administrator password. The installation takes a few minutes. - Verify the installation. After the installer finishes, close it. Open a new Terminal window (or the same one if it's still open) and type
python3 --versionagain. You should now see the version number you installed, likePython 3.12.4. If you see this, Python is installed and ready. - Run Python interactively. In Terminal, type
python3and press Enter. You'll see a prompt like>>>. This is the Python interactive shell. Typeprint("Hello, world!")and press Enter. You should seeHello, world!printed. To exit, typeexit()and press Enter. - Create and run a Python script. Open a text editor (like TextEdit, but make sure it's in plain text mode by going to Format > Make Plain Text). Type
print("Hello from a script!")and save the file ashello.pyon your Desktop. In Terminal, navigate to your Desktop by typingcd ~/Desktopand pressing Enter. Then run the script withpython3 hello.py. You should see the message printed. - Optional: Install a code editor. While Terminal is fine for small scripts, most developers use a code editor like Visual Studio Code, PyCharm, or Sublime Text. Download one from its official website and install it. Then you can open your
.pyfiles in the editor and run them from there (usually with a "Run" button or by pressing F5).
Common Mistakes
- Typing
pythoninstead ofpython3. On macOS, the commandpythonmay not work or may point to an older version. Always usepython3for the version you just installed. - Not opening a new Terminal window. If you had Terminal open before installing, it may not recognize the new Python installation. Close and reopen Terminal.
- Editing files in TextEdit with rich text. If you save as .rtf, the script won't run. Always use plain text format.
- Forgetting the file extension. Save your script with a
.pyextension, not.txt.
Tips
- Use a virtual environment. When you start working on real projects, create a virtual environment to keep dependencies separate. In Terminal, navigate to your project folder and run
python3 -m venv venv, then activate it withsource venv/bin/activate. - Update pip. pip is Python's package installer. After installing Python, run
python3 -m pip install --upgrade pipto make sure you have the latest version. - Set up an alias (optional). If you want to type
pythoninstead ofpython3, you can add an alias to your shell profile. Open~/.zshrc(or~/.bash_profileif you use bash) and addalias python=python3. - Use Homebrew (alternative). If you prefer a package manager, you can install Python with Homebrew by running
brew install python. This is useful if you already use Homebrew for other tools.
Troubleshooting
If the installer fails: Make sure you have enough disk space and try downloading the installer again. If you get a "cannot be opened because the developer cannot be verified" warning, go to System Settings > Privacy & Security and click "Open Anyway" next to the Python entry.
If python3 --version still shows nothing or an old version: Close and reopen Terminal. If that doesn't work, check that the installer actually completed. Try running which python3 to see where Python is installed. It should be something like /Library/Frameworks/Python.framework/Versions/3.x/bin/python3. If it's not there, re-run the installer.
If you get a "Permission denied" error when running a script: Make sure the file is readable. In Terminal, run chmod +x hello.py to make it executable (though for Python scripts you usually just run python3 hello.py without needing execute permissions).
If you see "No module named pip": This is rare, but you can install pip by running python3 -m ensurepip --upgrade.
If you accidentally installed multiple versions of Python: Use python3 --version to check which one is active. To manage versions, consider using pyenv (a version manager) or just uninstall the ones you don't need by deleting them from /Applications and /Library/Frameworks.
Frequently Asked Questions
Do I need to install Python separately if I have Xcode?
Xcode includes a version of Python, but it's usually older and not the full installation. It's recommended to install the official Python from python.org for the latest version and full functionality.
What's the difference between Python 2 and Python 3?
Python 2 is outdated and no longer supported. Python 3 is the current version. The installer from python.org gives you Python 3, which is what all modern libraries and frameworks use.
Can I use the Mac App Store to install Python?
There is a Python app on the Mac App Store, but it's often outdated. The official python.org installer is the most reliable and up-to-date method.
How do I uninstall Python from my Mac?
To remove the Python you installed from python.org, delete the Python folder from /Applications, and remove the framework at /Library/Frameworks/Python.framework. Also remove the symlinks in /usr/local/bin that point to Python. Be careful: this will break any projects that depend on it.
Why do I get a "command not found" when I type python?
macOS doesn't include a python command by default (only python3). If you want python to work, add an alias as described in the Tips section.
Can I run Python scripts by double-clicking them?
Yes, but you need to set the file to open with the Python launcher. Right-click the .py file, select "Open With", and choose "Python Launcher". However, this is less convenient for debugging, so using Terminal is recommended.