Why doesn't the command Python not do anything in Command Prompt?

Viewed 7265

The Command Prompt does not do anything when I use the Python command to execute a module. It does not even do anything when I use it at all; it just pretends that I did not do anything, and goes back to the current working directory. Attached is a screen shot for clarity.

Actual module

Not an actual module

6 Answers

Apparently, if you call python from Windows' Command Prompt (at least with my home computer), it will look for any python version installed using Windows Store, so if you just type python, it will open the Windows Store for you to install.

If you have Python installed, try to call full path to executable or try to add the path containing your Python executable (in my case, C:\Python38) to the system environment variable PATH:

  1. Search for "Edit the system environment variables".
  2. Click the Environment variables... button (in the Advanced tab)
  3. Edit PATH and append ;C:\Python27 to the end (substitute your Python version)
  4. Click OK and reopen cmd for change to take effect.

Update.

I simply uninstalled and reinstalled Python. Once I did that, the program works as it should in CMD.

enter image description here

If you have python already installed, you should just be able to type 'python' alone then press enter. It should then give you a space to execute python code. It could be simple fix, but if not it's still worth a shot.

When its the first time you're going to install python on Windows it shows you the option Add to path unchecked, so you just need to check that option and install python, you can uninstall python and installet again with the check, this fix the problem.

I just use the IDLE, it is the easiest way to run python scripts. Just open up IDLE and click on File < Open.. < and select your file. Then make any last minute changes and click on File < Save. Click on Run < Run Module (or F5) to run the python script. Done.

This is great for people that want to use python 2.7 or just don't want to install the python application from the Microsoft store.

Sometimes the order in which the PATH environment variable is set also matters; if the Windows store variable is before the path where Python is installed then the windows store will open when you type python.

Related