How To Fix Error Python Is Not Recognized As An Internal Or External Command Operable Program Or Batch File

The error message “python is not recognized as an internal or external command, operable program, or batch file” typically occurs when the Python executable is not found in the system’s PATH environment variable. This issue can be resolved by adding Python to the PATH or by reinstalling Python with the option to add it to the PATH during installation. Here’s how you can fix it.

1. Check if Python Is Installed.

Open a command prompt (Windows) or terminal (macOS/Linux) and type the command `python` or `python –version`. If Python is installed correctly, it will display the installed version. If it’s not installed, download and install Python from the official website: https://www.python.org/downloads/

2. Add Python to the PATH (Windows).

During the installation process, there is an option to “Add Python x.x to PATH.” Ensure that this option is selected. If you have already installed Python without this option, you can either reinstall Python with the option enabled ( refer to How To Install Python/Pip On Windows ) or manually add Python to the PATH.

2.1 Manually add Python to the PATH.

Find the installation path of Python (e.g., C:\Python39), you can read the article How To Find Where Python Is Installed On Mac, Linux, And Windows to learn more.

Open the Start menu, search for “environment variables” and select “Edit the system environment variables“. Click the “Environment Variables” button. In the “System variables” section, find the “Path” variable and click “Edit“.

Click “New” and enter the path to the Python executable (e.g., C:\Python39) and click “OK” on all open dialogs. You can refer to the article How To Set Windows Environment Variables.

3. Restart Your Command Prompt Or Terminal.

After making changes to the PATH environment variable, you must close and reopen any open command prompt or terminal windows for the changes to take effect.

4. Verify Python Is Recognized.

Open a new command prompt or terminal and type `python –version` to check if Python is now recognized and displays the installed version.

5. macOS and Linux.

If you’re using macOS or Linux, the steps are similar to adding Python to the PATH on Windows. However, macOS and most Linux distributions usually come with Python preinstalled. If you have issues, check your system’s Python installation and the PATH variable.

You can first read the article How To Find Where Python Is Installed On Mac, Linux, And Windows to get your Python installed directory on your OS. Then add the Python installed folder such as /usr/local/bin to the macOS or Linux PATH system environment variable.

You can read the article How To Change System Environment Variable Path Value On macOS & Linux Permanently to learn more. After following these steps, you should no longer encounter the “Python is not recognized” error, and you’ll be able to run Python commands from the command prompt or terminal.

6. Video Demo For This Article.

You can watch the video of this example article below.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.