Creating a Python local server in Windows

Posted on

Problem :

I’m trying to use this commmand:

python -m SimpleHTTPServer 

but it’s not working. I’m guessing that it isn’t working because I’m running that through Windows Command Prompt. How does one make that function?

The error I am getting from Command Prompt is:
“‘python’ is not recognized as an internal or external command, operable program or batch file”

Solution :

By default, python is not registered as a command in the windows command prompt. (Be it a file in the PATH, a macro or something else entirely).

The solution is to simply type the whole path to the python.exe. I installed Python to C:Python27 so all I need to type is

C:Python27python.exe /m SimpleHTTPServer 

Based on the error you provided, it looks like you didn’t add Python to your path environment variable.

If you recently installed Python 3.x, try searching for “Python” in windows file explorer. Mine was installed under:
C:UsersXXXXAppDataLocalProgramsPythonPython36-32

Use Command prompt to navigate to this directory, and then type “Python.exe – m http.server”

You should be good to go.

Leave a Reply

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