Site icon ni18 Blog

Fix “zsh: command not found: python” Error on macOS Monterey 12.3

Running into the “zsh: command not found: python” error on macOS Monterey 12.3 when using Python 3.10 with Atom IDE and the atom-python-run 0.9.7 package? This issue often occurs because macOS 12.3 removed the pre-installed Python 2, and the python command no longer points to python3. Additionally, the atom-python-run package may incorrectly call python instead of python3. Here’s a simple guide to fix it.

Why This Error Happens

Starting with macOS Monterey 12.3, Apple removed the default Python 2 installation, causing commands expecting python to fail if Python 3 is installed. The atom-python-run package in Atom IDE may still use python instead of python3, leading to the error. Let’s resolve this step-by-step.

Steps to Fix the “zsh: command not found: python” Error

1. Verify Python 3.10 Installation

Ensure Python 3.10 is installed correctly.

2. Create an Alias for Python

Since macOS expects python3 but Atom’s atom-python-run may call python, create an alias to map python to python3.

3. Update Atom’s atom-python-run Settings

The atom-python-run package may still call python instead of python3. Update its settings to fix this.

4. Alternative: Use a Symbolic Link

If the alias doesn’t work for atom-python-run, create a symbolic link to make python point to python3.

5. Optional: Use pyenv for Python Version Management

To manage multiple Python versions and avoid conflicts, use pyenv.

Common Issues and Fixes

Troubleshooting Table

IssueSolution
python3 not foundInstall Python via brew install python@3.10
Alias not persistingAdd alias to ~/.zshrc and run source ~/.zshrc
atom-python-run uses pythonUpdate package settings to use python3
Multiple Python versionsUse pyenv to manage versions

Helpful Resource

For more on managing Python environments, visit pyenv’s official guide. It’s a great tool for handling multiple Python versions on macOS!

Exit mobile version