How to run a python program in the Command prompt in windows 10


#1

I am relatively new to python. I have been trying to run python programs in command prompt. But I am getting an error message as such:
‘python’ is not recognized as an internal or external command, operable program or batch file.


#2

Hi @Jyothi_Lekshmi

I assume you have already installed python 2.7 .The above error is because you have not added C:\Python27 to your system PATH variable.
For that,

  1. Goto the Start Menu
  2. Right Click “Computer”
  3. Select “Properties”
  4. A dialog should pop up with a link on the left called “Advanced system settings”. Click it.
  5. In the System Properties dialog, click the button called “Environment Variables”.
  6. In the Environment Variables dialog look for “Path” under the System Variables window.
  7. Add “;C:\Python27” to the end of it. The semicolon is the path separator on windows.
  8. Click ok and close the dialogs.
  9. Now open up a new command prompt, type “python” and hit enter

Now, a new python shell will open ‘or’ alternatively you may try the below method in command prompt.

C:\Python27\python.exe C:\Users\Username\Desktop\my_python_script.py

Regards!


#3

Hello,
Its very easy to make python (any version) work with command prompt. Just add python path to Environment Variables.


#4

I have installed python3.6. Even though I have appended as above.Its not working.Can you help?


#5

You have to be more specific. Have you added the path of python 3.6 to the environment variables??
If yes, do you have any new error message ??


#6

I have appended the path as follow:
;C:\Python36 But it shows the same error message as,“Python is not recognized as internal or external command ,operable program or batch file”


#7

Hi,
First of C:\Python36 is not the path of Python 3.6. You need to undo all the changes made in Environment variable. Then Uninstall python 3.6. Then Install it again, this time when you install check the Add Python 3.6 To PATH, like this;

After install, open command prompt, type python and hit enter.

Voila!!


#8

Thank you. It actually worked. :grinning::grinning: