‘python’ is not recognized as an internal or external command, operable program or batch file

‘python’ is not recognized as an internal or external command, operable program or batch file

So you got the ‘PYTHON’ IS NOT RECOGNIZED AS AN INTERNAL OR EXTERNAL COMMAND, OPERABLE PROGRAM OR BATCH FILE error on your windows machine when trying to set up a new workstation? Maybe you’re new to Python and this is your first error ever? Regardless, it’s cutting into valuable procrastination time so let’s get er’ done.

The Problem: ‘PYTHON’ IS NOT RECOGNIZED

You’ve downloaded Python, installed Python, tried to run it in the command line and got the ‘PYTHON’ IS NOT RECOGNIZED AS AN INTERNAL OR EXTERNAL COMMAND, OPERABLE PROGRAM OR BATCH FILE error. If you haven’t downloaded and installed it then go download and install it. If the problem persists then come back.

Assuming that Python is now installed, then the error is happening because Python’s location can’t be found in the environment variable “path.” You’ll need to first find where Python is located and then add it the path environment variable.

Finding Python’s Path

If Python is installed then you should be able to find it from the Windows search bar located typically on the lower left of your screen.

Type “Python” in it and smash enter. This will take you directly to a Python terminal. Now we need to find where this program is located. We’ll do this by executing the following.

import os
os.getcwd()

This should print out something like the following.

'C:\Users\YourUserNameHere\AppData\Local\Programs\Python\Python37-32'

This is the location of your Python installation. We need to get this into the path variable. Now, let’s get back to the Windows search bar. Type “environment” into it and smash enter again. This will launch the following.

Click “Environment Variables…” This will launch another window titled “Environment Variables.” We’re going to want to double click “Path” in the top section of this window.

This will bring up the following screen. Click new and paste the path you pulled from Python using os.getcwd()

Don’t forget to remove any double back slashes in the path Python output. Make sure to restart any active terminals and you should now be good. Happy coding! Check out our most recent Python post for more shenanigans.

Leave a Comment