Setting a predictable default Python interpreter matters when terminal commands, editor tasks, or lightweight automation invoke python without a version suffix. Choosing that command explicitly avoids bouncing between runtimes on hosts that keep several Python 3 minor versions installed side by side.
On Linux and macOS, the shell resolves python by searching the directories in PATH from left to right. Current PEP 394 guidance leaves the unversioned python command flexible on Unix-like systems, so one host may map it to Python 3, another may omit it entirely, and an activated virtual environment may temporarily replace it with a project-local interpreter.
A user-owned shim in ~/.local/bin keeps the change inside one account and puts that directory ahead of the rest of the interactive shell path. Scripts that call an explicit interpreter path, shebang-managed entry points, and activated virtual environments continue to select their own runtime instead of inheriting the user default blindly.
Related: How to check Python version
Related: How to create a virtual environment in Python
Steps to set the default Python interpreter in the shell:
- Resolve the full path of the versioned interpreter that should answer python.
$ command -v python3.14 /usr/local/bin/python3.14
Replace python3.14 with the installed interpreter that should become the default, such as python3.13 or python3.12. Other systems may resolve the binary under /usr/bin, /usr/local/bin, or an Apple Silicon Homebrew prefix such as /opt/homebrew/bin.
- Create a user-local binary directory when it is not already present.
$ mkdir -p ~/.local/bin
- Point a user-owned python shim at the chosen interpreter.
$ ln -sf "$(command -v python3.14)" ~/.local/bin/python
This changes only the unversioned python command for the current user. PEP 394 recommends implementing a configurable python command as a link to the interpreter rather than replacing the interpreter binary itself.
- Add export PATH="$HOME/.local/bin:$PATH" to the interactive shell startup file that owns the session path.
$ vi ~/.zshrc export PATH="$HOME/.local/bin:$PATH"
Use /.bashrc for non-login Bash shells, /.bash_profile or /.profile for login Bash shells, and /.zshrc for Zsh.
- Reload the same startup file and clear the shell command hash before testing the new default.
$ source ~/.zshrc $ hash -r
Replace /.zshrc with the file edited in the previous step, such as /.bashrc or /.bash_profile.
- Confirm that python now resolves through the user shim and that the final executable is the intended runtime.
$ command -v python /Users/analyst/.local/bin/python $ python --version Python 3.14.3 $ python -c "import sys; print(sys.executable)" /usr/local/opt/python@3.14/bin/python3.14
sys.executable shows the interpreter that actually ran after following the shim. An activated virtual environment prepends its own bin directory and temporarily overrides this selection until the environment is deactivated.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
