# How to execute a python macro

**URL:** <https://root-forum.cern.ch/t/how-to-execute-a-python-macro/40309>\
**Category:** Newbie\
**Tags:** python\
**Created:** [July 8, 2020, 5:21am UTC](https://root-forum.cern.ch/t/how-to-execute-a-python-macro/40309 "2020-07-08T05:21:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Finkelstein](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edward_finkelstein/32/20070_2.png) [@Edward\_Finkelstein](https://root-forum.cern.ch/u/Edward_Finkelstein)\
**Post date:** [July 8, 2020, 5:21am UTC](https://root-forum.cern.ch/t/how-to-execute-a-python-macro/40309/1 "2020-07-08T05:21:43Z")

</div>

* * *

Hello,  
I am trying to execute a python code in Pyroot, but I don’t know how to do it. I know that to execute a macro at the root prompt, one types .x \<file\_name\> but how do you do that for a python code?

_ROOT Version:_ 6.23/01

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 8, 2020, 5:46am UTC](https://root-forum.cern.ch/t/how-to-execute-a-python-macro/40309/2 "2020-07-08T05:46:25Z")

</div>

```auto
$ python macro.py

```
