# Run a Python file in Command Prompt

**URL:** <https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577>\
**Category:** Python Help\
**Created:** [December 21, 2023, 12:42am UTC](https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577 "2023-12-21T00:42:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/gabriel/32/16603_2.png) [@Gabriel](https://discuss.python.org/u/Gabriel)\
**Post date:** [December 21, 2023, 12:42am UTC](https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577/1 "2023-12-21T00:42:11Z")

</div>

How to run a Python file in Windows Command Prompt using the imput command?

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [December 21, 2023, 1:51am UTC](https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577/2 "2023-12-21T01:51:01Z")

</div>

You can’t. But look at the subprocess module, which allows to run pretty much anything.

---

<div class="post-metadata">

**Author:** ![cameron](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cameron/32/2658_2.png) [@cameron](https://discuss.python.org/u/cameron)\
**Post date:** [December 21, 2023, 3:24am UTC](https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577/3 "2023-12-21T03:24:46Z")

</div>

Can you elaborate a bit on what you mean here?

IIRC on Windows the Python interpreter is invoked as “py”, so:

```
 py your-python-file.py

```

would be my first guess.

Cheers,  
Cameron Simpson [cs@cskk.id.au](mailto:cs@cskk.id.au)

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [December 21, 2023, 5:16am UTC](https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577/4 "2023-12-21T05:16:56Z")

</div>

It’s not clear what you mean by this, because “using the imput command” doesn’t make sense. There are a few things that I could guess you are trying to say, but the answer would be very different depending on that.

---

<div class="post-metadata">

**Author:** ![FelixFourcolor](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/felixfourcolor/32/13104_2.png) [@FelixFourcolor](https://discuss.python.org/u/FelixFourcolor)\
**Post date:** [December 21, 2023, 6:10am UTC](https://discuss.python.org/t/run-a-python-file-in-command-prompt/41577/5 "2023-12-21T06:10:55Z")

</div>

I think by “input command” OP meant the command prompt (as in the question title). @cameron’s answer is my guess.
