- ‘python’ is not recognized as an internal or external command, operable program or batch file.
- Adding Python to the Windows PATH Environment Variable
- Python is not recognized as an internal or external command, operable program or batch file
- What is Environment variables?
- Option 1) Adding a Python to the PATH Environmental Variable in Windows
- Option 2) Adding Python to Windows Environmental Variable using Python Installer
- How to fix ‘python3’ is not recognized as an internal or external command, operable program or batch file
- Take your skills to the next level ⚡️
- About
- Search
- Tags
- [Fix] ‘python’ is not recognized as an internal or external command, operable program or batch file
- Reason for “’python’ is not recognized as an internal or external command”
- Step 1: Install Python on your computer
- Step 2: Set PATH variable
- Final words:
- Share this:
‘python’ is not recognized as an internal or external command, operable program or batch file.
The ‘python’ is not recognized as an internal or external command, operable program or batch file. error is encountered in the command prompt of Windows after you install Python on the windows machine. The error is raised when Python executable file path is not added in an environment variable.
Since the problem is at execution, windows will not let you execute any Python code, even on the command prompt, and throws an error “Python is not recognized as an internal or external command.“
So what does this error mean, and why does it appear in the first place? Well, whenever you run any python code on your computer, the installed Python library is the one that will compile and execute the code. If you run the code in the same path where the Python executable is located, your code executes properly.
If you run it in any other path, then windows won’t know how to execute your code, and this can be resolved by adding Python executable in an environment variable.
Adding Python to the Windows PATH Environment Variable
Let’s go step by step process to add python to path windows 10 environment variable.
Step 1: Assuming that you have already installed Python on your windows machine, as a first step, locate the folder path where you have installed the Python. Usually, it will be in the OS directory “C:\Program Files\Python3.x” or inside “C:\Users\\AppData\Local\Programs\Python\Python3.x” it may vary if you have installed OS in a different drive or Python is installed in a different directory. Alternatively, take the help of windows search in locating the file.
Step 2: Once you locate the file, right-click again and choose “Properties.” Copy the full “Location” path.
Step 3: Right-click This PC, then go to Properties => Advanced system settings => Environment variables.
Step 4: You’ll see your variables here. Select the PATH variable and click the “Edit” button. In the window that appears when a path variable exists, select it and click Edit; otherwise, click New.
Step 5: Finally, paste the path you copied earlier in Step 1. If your system has many paths linked by semicolons, append the path by prefacing it with a semicolon. Click Ok to save.
Once you have completed all the steps, try running the Python program from your command prompt. You can run the ‘py’ or ‘python’ command, and you should not see any error hereafter. Remember to close all the command prompt windows and reopening them again after completing the above steps.
If you are downloading and installing the latest version of Python 3.6+, then during the installation itself, the installer will prompt you to automatically add the Python to system PATH.
Python is not recognized as an internal or external command, operable program or batch file
But before that, we need to know what is Environment variables in Windows and its role.
What is Environment variables?
Environment variables are variables that create the environment in which programs runs in your computer. It enables the user to specify the directory to install files in, location to store temporary files, and also the location to find user profile settings. In the same way, the python environment variable help system to specify the location of the python executable.
Option 1) Adding a Python to the PATH Environmental Variable in Windows
Here is step by step process of adding a full path of python distribution in Environmental Variable:
1.Open Computer/System Properties
Press (Windows Key) and Type «This PC» then right-click on Computer (This PC) and select Properties.
2. Inside ‘Property’ window click on ‘Advanced system settings’
3. Now click Environment Variables button at the bottom (here we will add the full path of python distribution).
4. In the ‘Environment Variables’ window select ‘Path’ variable and click ‘Edit’.
5. Now click on the ‘New’ button to add Python Environment Variable.
For Example: «C:\WINDOWS\system32;C:\WINDOWS;C:\Python32”
Note: C:\Python32: is your python installation directory.
In the latest version of Python the setup get installed in
«C:\Users\Shalesh\AppData\LocalPrograms\Python\Python37-32\Scripts»
6. Click ‘OK’ to save the changes and then run Python command from the command prompt.
Note: The procedure explained above works fine with Windows 7, Windows 8 (8.1) and Windows 10
Option 2) Adding Python to Windows Environmental Variable using Python Installer
1.Download the same version of Python executable installer from Python.org (https://www.python.org/downloads/release/python-374/)
Note: In this tutorial, we are using Python 3.7
2. Run python Setup and select the ‘Modify’ button
3.In the next window click ‘Next’
4. In ‘Advanced Options’ window check ‘Add Python to environment variables’ and click on ‘Install’.
Note: You don’t need to uninstall the older version of python, just modify the previous installation.
Now if you run python through command prompt it will give you the following result:
C:Usersmypc>python Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
This implies that all is OK and your system is ready to run python
- Learn Python Programming
- Python Online Compiler
- Addition of two numbers in Python
- Python vs PHP
- TypeError: ‘int’ object is not subscriptable
- Python Factorial
- Top Online Python Compiler
- Polymorphism in Python
- Python String Concatenation
- Python eval
- Python zip()
- Python String Title() Method
- Python Print Without Newline
- Id() function in Python
- Reverse Words in a String Python
- Only Size-1 Arrays Can be Converted to Python Scalars
- Bubble Sort in Python
- Python slice() function
- Compare Two Lists in Python
- Pangram Program in Python
How to fix ‘python3’ is not recognized as an internal or external command, operable program or batch file
In Windows, running the python3 command might give you the following error:
This error occurs because the python3 alias is only created by default in Linux-based OS like Ubuntu and macOS.
For Windows OS, the command to run Python from the console is either python or py as shown below:
If you want to use the python3 alias, then you can rename the python.exe file in your programs folder to python3.exe :
But keep in mind that this will disable the py and python commands from the command prompt:
If you also want to keep the original commands working, then you need to copy the executable file so that you have both python.exe and python3.exe in your path:
This way, Windows automatically refer to the right executable file for the alias you used.
And that’s how you get to fix the ‘python3’ is not recognized as an internal or external command error in Windows.
I hope this tutorial helps. Until next time! 👋
Take your skills to the next level ⚡️
I’m sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I’ll send new stuff straight into your inbox!
About
Hello! This website is dedicated to help you learn tech and data science skills with its step-by-step, beginner-friendly tutorials.
Learn statistics, JavaScript and other programming languages using clear examples written for people.
Search
Type the keyword below and hit enter
Tags
Click to see all tutorials tagged with:
[Fix] ‘python’ is not recognized as an internal or external command, operable program or batch file
Python is the most widely used high-level web application development language. With the simple syntax, it was designed to improve the readability of the programs. It runs on the Interpreter system which helps to execute the code as soon as it is written. If you are writing a code using Python programming then you may have come across the error “‘python’ is not recognized as an internal or external command operable program or batch file”.
This article will help you to learn about the exact cause of this error and how to get rid of this python error.
Reason for “’python’ is not recognized as an internal or external command”
As mentioned in the error message, your computer is not able to find and execute the required python executable. That is why it’s throwing the error ‘python’ is not recognized as an internal or external command.
There are two major reasons which may result in this error message i.e. either Python is not installed on your computer or the system environment variable is not set.
Follow the below steps to fix the error while executing your first Python program.
Step 1: Install Python on your computer
Check whether you have installed Python or not. If you have not installed Python on your system and trying to use the python command then it is obvious to get the error message as this functionality is not available on your computer.
If you have not installed python then install the latest version of python on your environment.
Read: Steps to install Python and run your first program
If you have already installed Python on your computer and still getting the error, follow the next step.
Step 2: Set PATH variable
Note: Here we are assuming you have installed python on your environment.
If you have installed python and still you are getting the error message then check for the system PATH variable. Either you have not entered the python executable path in the PATH system variable or the entered path is incorrect.
Here are the steps to set the correct python executable path in the environment variable.
- Go to Control Panel –> System and Security –> System
- Click on Advanced system settings. It opens the ‘System Properties’ dialog box.
- In the ‘System Properties’ dialog box, select the Advanced tab and click on the ‘Environment variables…‘ button as shown below to open the environment variable window.
Note: Make sure to set the value in the ‘System variable’ section and not in the user variable.
Note: After setting the environment variable, make sure to use a new command prompt to execute the python command again. If you tried to run the python command on the same command prompt then you will again get “python is not recognized as an internal or external command” error message as the new path will not be reflected in the same cmd session.
Final words:
- Install python compiler.
- Set system Path variable value.
- Run command on a new command prompt.
Easy, isn’t it? Do let us know whether you are able to fix this error with the above steps in the comment section. Cheers!