How to Run Python Files in Windows Command Prompt? [Duplicate]

I want to run a python file in my command prompt but it does nothing. These are the screen shots of my program i am testing with and the output the command prompt gives me.

2

First set path of python

and run python file

python filename.py

command line argument with python

python filename.py command-line argument

You have to install Python and add it to PATH on Windows. After that you can try:

python `C:/pathToFolder/prog.py`

or go to the files directory and execute:

python prog.py

First go to the directory where your python script is present by using-

cd path/to/directory

then simply do:

python file_name.py
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest