# How can I use external Python script in paraview&

**URL:** https://discourse.paraview.org/t/how-can-i-use-external-python-script-in-paraview/8081
**Category:** ParaView Support
**Tags:** python
**Created:** [September 26, 2021, 6:13pm UTC](https://discourse.paraview.org/t/how-can-i-use-external-python-script-in-paraview/8081 "2021-09-26T18:13:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nickola](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@Nickola](https://discourse.paraview.org/u/Nickola)
#### Post date: [September 26, 2021, 6:13pm UTC](https://discourse.paraview.org/t/how-can-i-use-external-python-script-in-paraview/8081/1 "2021-09-26T18:13:00Z")

</div>

Hello everybody!What is a correct way to execute some external python script from disk? Iuse  
execfile(‘full\_path/script.py’) , but see ‘execfile is not found’. Where is a mistake? Where is a documentation  
about that? Please help!

---

<div class="post-metadata">

### Author: ![Azrael3000](https://discourse.paraview.org/user_avatar/discourse.paraview.org/azrael3000/32/7648_2.png) [@Azrael3000](https://discourse.paraview.org/u/Azrael3000)
#### Post date: [September 27, 2021, 8:53am UTC](https://discourse.paraview.org/t/how-can-i-use-external-python-script-in-paraview/8081/2 "2021-09-27T08:53:08Z")

</div>

```auto
exec(open("./filename").read())

```

See: [What is an alternative to execfile in Python 3? - Stack Overflow](https://stackoverflow.com/questions/436198/what-is-an-alternative-to-execfile-in-python-3#16577427)

---

<div class="post-metadata">

### Author: ![Nickola](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@Nickola](https://discourse.paraview.org/u/Nickola)
#### Post date: [October 7, 2021, 3:00pm UTC](https://discourse.paraview.org/t/how-can-i-use-external-python-script-in-paraview/8081/3 "2021-10-07T15:00:48Z")

</div>

Thank you for your answer! I used “exec” but now it does not work because " “self” is not defined". Meanwhile I run using copy-paste it works!

---

<div class="post-metadata">

### Author: ![Azrael3000](https://discourse.paraview.org/user_avatar/discourse.paraview.org/azrael3000/32/7648_2.png) [@Azrael3000](https://discourse.paraview.org/u/Azrael3000)
#### Post date: [October 8, 2021, 8:51am UTC](https://discourse.paraview.org/t/how-can-i-use-external-python-script-in-paraview/8081/4 "2021-10-08T08:51:02Z")

</div>

Check the exec documentation:

[https://docs.python.org/release/3.2.3/library/functions.html#exec](https://docs.python.org/release/3.2.3/library/functions.html#exec)

You have 2 more arguments that can be used to pass global and local variables
