[Solved] Python http.server command gives “Syntax Error” [closed]


Because you’re having trouble understanding what we mean in the comments; you need to run the command

python -m http.server 8000 --bind 127.0.0.1

from a bash (or similar) shell, NOT from the python IDLE interpreter. They do not mean the same thing. You would have to type the command python into your shell in order to get to you Python IDLE interpreter.

If you’re in your python interpreter and would like to exit, press Ctrl+D to return to your bash (or similar) shell. Then, execute the command

python -m http.server 8000 --bind 127.0.0.1

and it should work.

You are right that the python documentation for httpserver could be made more clear but you should know that when you see a call to python it’s almost certainly being made from a shell.

2

solved Python http.server command gives “Syntax Error” [closed]