How Can I Fix The “zsh: Command Not Found: Python” Error? (macos Monterey 12.3, Python 3.10, Atom IDE, And Atom-python-run 0.9.7)

The "zsh: command not found: python" error typically occurs when the system cannot locate the Python executable in the shell’s PATH. To fix this error, you can try the following steps:

  1. Verify Python Installation: Ensure that Python is properly installed on your Mac by opening a terminal and typing python3 --version. This should display the installed Python version. If it returns an error, you may need to reinstall Python.

  2. Check PATH variables: Open a terminal and type echo $PATH to check the current PATH variables. Make sure the Python executable path is included in the output. The path should generally include /usr/local/bin or /usr/bin.

  3. Adjust PATH in shell config file: To set the correct PATH, you can modify the shell configuration file (e.g., .zshrc or .bash_profile). Open the terminal and enter the following command to edit the file:

    nano ~/.zshrc

    In the editor, add the following line at the end of the file:

    export PATH="/usr/local/bin:$PATH"

    Save the file by pressing Ctrl + X, followed by Y, and then Enter.

  4. Restart shell or reload config: To apply the changes, either close and reopen the terminal or reload the shell configuration file by running:

    source ~/.zshrc
  5. Test Python command: Finally, verify that the Python command works by running python3 --version in the terminal. It should display the installed Python version without any errors.

After following these steps, the "zsh: command not found: python" error should be resolved, and you can use Python in your Atom IDE as expected.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!