# How to run Python Terminal

**URL:** <https://discuss.python.org/t/how-to-run-python-terminal/74519>\
**Category:** Python Help\
**Tags:** help\
**Created:** [December 17, 2024, 10:57am UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519 "2024-12-17T10:57:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joni](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@Joni](https://discuss.python.org/u/Joni)\
**Post date:** [December 17, 2024, 10:57am UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519/1 "2024-12-17T10:57:33Z")

</div>

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`

 ![Untitled 863](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/a/d/addacc96f41b438eb34179ee54311a700c30ebd9.png)

---

<div class="post-metadata">

**Author:** ![Joni](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@Joni](https://discuss.python.org/u/Joni)\
**Post date:** [December 17, 2024, 11:03am UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519/2 "2024-12-17T11:03:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rfletchr](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rfletchr/32/24563_2.png) [@rfletchr](https://discuss.python.org/u/rfletchr)\
**Post date:** [December 17, 2024, 11:38am UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519/3 "2024-12-17T11:38:52Z")

</div>

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

```python
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
python D:\python_projects\hello.py

```

---

<div class="post-metadata">

**Author:** ![Joni](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@Joni](https://discuss.python.org/u/Joni)\
**Post date:** [December 17, 2024, 11:51am UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519/4 "2024-12-17T11:51:20Z")

</div>

This is running fine.

> [@rfletchr](#):
>
> ```python
> import sys
> print(sys.version)
> 
> ```

I am not able to run

```python
python D:\python_projects\hello.py

```

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

 ![Untitled 864](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/2/d/2d2d715534150b8d972205c13843b56f7ca8a0b0.png)

---

<div class="post-metadata">

**Author:** ![rfletchr](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rfletchr/32/24563_2.png) [@rfletchr](https://discuss.python.org/u/rfletchr)\
**Post date:** [December 17, 2024, 12:10pm UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519/5 "2024-12-17T12:10:31Z")

</div>

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.

> **[Windows Terminal FAQ](https://learn.microsoft.com/en-us/windows/terminal/faq)**
>
> Frequently asked questions about Windows Terminal, such as how to start terminal in administrator mode, how to save a terminal session, and more.

RealPython have a explainer which should help you.

> **[How to Run Your Python Scripts and Code – Real Python](https://realpython.com/run-python-scripts/)**
>
> A Python script or program is a file containing executable Python code. Being able to run Python scripts and code is probably the most important skill that you need as a Python developer. By running your code, you'll know if it works as planned.

---

<div class="post-metadata">

**Author:** ![Joni](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@Joni](https://discuss.python.org/u/Joni)\
**Post date:** [December 17, 2024, 1:58pm UTC](https://discuss.python.org/t/how-to-run-python-terminal/74519/6 "2024-12-17T13:58:45Z")

</div>

I manage to run the following in `cmd`

```python
python D:\python_projects\hello.py

```
