Alias python3 to python
How to alias python3 to python on Mac. Using the Mac system Python.
An alias is a shortcut you define in a shell configuration file that makes one command stand in for another. Aliasing python to python3 means you can type python and have the shell run python3 for you.
Your Mac may have Python 3 installed as python3 with no python command at all. For convenience, you may want to alias python3 to python so you can use Python in the way you expect.
Aliasing python3 to python is one step in setting up your Mac for development. See the guide to set up a Mac for development.
Before you get started
You'll need a terminal application to set and use a command-line alias. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
A python alias is usually the wrong choice
An alias is the right fix in one situation only: when you want to use Apple's system Python. And usually you are better off installing a newer Python than using Apple's system Python. If you installed Python with Homebrew, pyenv, uv, or the python.org installer, setting the Mac PATH is the better fix, and in some cases you need no fix at all. The next section explains which case you are in.
When you attempt to run Python, you may see:
$ python ...
zsh: command not found: python
You'll see zsh: command not found: python because you are trying to run the Python interpreter in the terminal. The error message shows that the Zsh shell ("the command line interpreter") cannot find the Python command. See the article command not found python for help.
Why prefer a $PATH change over an alias when you have the choice? An alias only applies to your own interactive terminal sessions. It is invisible to scripts, build tools, editors, and anything else that runs a non-interactive shell, so a project that works when you type commands by hand can still fail when a tool runs the same command. A $PATH entry works everywhere.
Differences between python and python3
Both commands run Python 3. Python 2 reached end of life in 2020, so the difference is not the version. It is whether the python command exists at all, and that depends on how Python was installed.
When Python 2 and Python 3 were both in use, the python command usually meant Python 2, so installers avoided providing it. PEP 394, the standard that governs this, still permits a distributor to "not provide python command" at all. That is why your Mac may have python3 and nothing else.
What each installation method gives you:
- Apple's system Python (from Xcode Command Line Tools) installs
/usr/bin/python3only. This is the case an alias solves, because no$PATHchange can add apythoncommand that Apple does not ship. - Homebrew installs
python3, and also an unversionedpythonin alibexec/bindirectory that is not on your$PATH. Do not use an alias here. Set the Mac PATH instead, as described in Install Python with Homebrew, and you get a realpythoncommand. - The official python.org installer installs
python3and version-numbered commands in/usr/local/bin, with no unversionedpython. An alias works, but most developers are better served by uv. See Download Python for Mac. - Pyenv provides both
pythonandpython3through its shims. No alias needed. - The uv utility installs both
pythonandpython3in~/.local/bin. No alias needed.
Is the system Python installed?
Try python3 --version and which -a python3 to check if Python was installed with Xcode Command Line Tools.
$ python3 --version
Python 3.9.6
$ which -a python3
/usr/bin/python3
If you have Python 3.9.6 installed at /usr/bin/python3, you have the system Python installed by Xcode Command Line Tools. If you just want to run a Python script or utility, you can use the system Python. If you intend to start a programming project, you should install a newer version of Python. See our guide Update Python.
For running the occasional Python utility, you can alias the python command to python3 and use the system Python installed by Xcode Command Line Tools.
How to set an alias
Set aliases in the ~/.zshrc (Zsh Run Control) file. The tilde ~/ is a Unix abbreviation for your home directory. That is, the .zshrc file belongs in your home directory. The article .zshrc or .zprofile explains why we use ~/.zshrc for setting aliases.
You can use TextEdit, the default macOS graphical text editor, to edit the shell configuration files. You can open a file in TextEdit from a terminal application:
$ open -e ~/.zprofile
You also can use the command line editors nano or vim to edit the shell configuration files. See Shell Configuration for more about editing shell configuration files.
Alias the python3 command
If you want to use Python to run a stand-alone application, utility, or script, and you have Python 3.9.6 installed, you can create an alias to use python as python3. Add the following line to your .zshrc file:
alias python='python3'
For this change to take effect, you'll either need to restart your terminal or reload your .zshrc file by entering source ~/.zshrc.
Entering python --version should now display the Python version number. This solves the error zsh: command not found: python. But you need to know more before trying to install and run a Python application.
Install utilities with UV or Pipx
READMEs and tutorials often suggest installing Python utilities with pip install. This is not recommended because it installs the program globally and can cause conflicts with other programs. Often, package installation fails with error: externally-managed-environment (see error: externally-managed-environment). Instead, Install UV or Install Pipx to put Python applications in isolated environments. With UV or Pipx, you can use the system Python without interfering with system software.
Install Python for programming
If you are starting a programming project with Python, don't use the system Python installed by Xcode Command Line Tools. There are several ways to install Python on a Mac. You can install Python with Homebrew or use a Python version manager such as UV or Pyenv.
If you're developing Python software projects, ask yourself if you're just going to develop one project or if you need to work on multiple Python projects. For a single project you can use brew python to install Python with Homebrew but you won't be able to easily switch between Python versions. For multiple projects, switching among Python versions, I recommend to Install UV, an all-in-one tool for managing Python projects. Alternatively, you can Install Pyenv to manage Python versions but it is older and more cumbersome than UV.
Continue setting up your Mac
Don't miss the full visual roadmap and checklist that shows how to set up a Mac for software development, with all the essential tools and settings you might not yet know about.