When you install python, sometimes you get this error – “‘python’ is not recognized as an internal or external command, operable program or batch file.” This is because either the installation was corrupt or the path to the executable is not set correctly.
Set path during installation
While installing Python using MSI installer, it gives you an option to add the path to your windows environment. Check that option.
This will solve the python not recognized error.
If path size is large
Sometimes the python path is so large that windows prevent it to enter into environment. This problem occurs when you install it into a custom location or your windows username is long. By default, the maximum path size limit is 260 characters. But you can increase it to 32,000 characters. Follow the below steps –
- Open Run
- Input Regedit and press enter. It will open registry editor.
- Go to this location – HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Now restart your computer.
Setting path using Environment Path window
Follow these steps –
Get your python installation path. Generally it is –
C:\Program Files\PythonXX. (XX means your python version like mine is 36)
Search environment variables and select “Edit the system environment variables“
The next window will be system properties. Click on Environment Variables button.
You will be presented with environment window from where you can add python path.
Now close all environment windows because the path updates will only happen when you close these windows.
This will solve your problems of python not getting recognized as internal or external command or as a batch file.