How to run Python Terminal

I am using Windows operating machine.

In start menu I found “Python 3.12.7 (64 bit)”

But when I type python-v I am not able to get the python version. I think I am missing packages maybe. Kindly have a look at the attached image and let me know how to fix the problem.

It says NameError: name 'python' is not defined

I latter need to open/run a file at the following location.

D:\python_projects\hello.py

Kindly let me know to run the hello.py file.

to answer your first problem, your typing python -v into the python interpreter. python -v only works on the command line (running cmd directly)

the image you posted is a running version of python itself so it will only understand python syntax

import sys
print(sys.version)

you need to open windows terminal and from there you can type python -v

to answer your second question enter the following command

python D:\python_projects\hello.py

This is running fine.

I am not able to run

python D:\python_projects\hello.py

See attachment. Please let me know how to run the hello.py.

again your trying to run shell commands inside the python interpreter. open Windows Terminal with either cmd or powershell and the command should work.

cmd, powershell and python are all different programs and expect different inputs. when you open Python 3.12.7 (64 bit) your running a python interpreter. This will only understand python code.

python D:\python_projects\hello.py is a shell command which only cmd or powershell will understand.

The python program is for running python code. cmd and powershell are for running other programs.

RealPython have a explainer which should help you.

I manage to run the following in cmd

python D:\python_projects\hello.py