# pvpython how to run startup script

**URL:** https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970
**Category:** ParaView Support
**Created:** [April 16, 2021, 12:17am UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970 "2021-04-16T00:17:47Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [April 16, 2021, 12:17am UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/1 "2021-04-16T00:17:47Z")

</div>

When I run pvpython, it does not initialize with the famous "from paraview.simple import \* ".

Is there a way to execute a series of commands when we start up pvpython? Examples are above, or setting a “Reverse Connection” in order to connect to a back end server.

@utkarsh.ayachit @cory.quammen

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [April 16, 2021, 7:21am UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/2 "2021-04-16T07:21:33Z")

</div>

I’ve been placing `from paraview.simple import *` at the top of my pvpython scripts

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [April 16, 2021, 11:29am UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/3 "2021-04-16T11:29:11Z")

</div>

`pvpython` is simply a standard Python interpreter. I don’t think we should do much more than that standard Python interpreter does. It’s best for users to realize that it is a standard Python interpreter and treat it as such.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [April 16, 2021, 6:20pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/4 "2021-04-16T18:20:50Z")

</div>

The reason for the question is I am trying to create scripts that automate pvpython connecting to a backend server. I would prefer not having the user be forced to type the Reverse Connection command. This is a request from Greg W.

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [April 16, 2021, 7:10pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/5 "2021-04-16T19:10:00Z")

</div>

Just write the following at the top of your script

```auto
from paraview.simple import *
ReverseConnect()

# [...]

```

See [Reverse connection](https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/simple.py#L106)

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [April 16, 2021, 8:51pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/6 "2021-04-16T20:51:40Z")

</div>

Seb,  
This is for other users. Thus, if I hard code pvpython with a script (of mine), users won’t then be able to run their own script. What I’m trying to do is create a client, and server pair of scripts that allow a user to run pvpython2cluster (with all of the magic hidden). If I am then passing in a script under the covers, users then won’t be able to do pvpython2cluster usersScript. Or, am I missing something?

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [April 16, 2021, 8:55pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/7 "2021-04-16T20:55:48Z")

</div>

I think you can load another script from the args and execute it inside your context…

You can obviously create an alias or equivalent of the first part of such command line:

`pvpython wait-cluster.py user-script.py`

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [April 30, 2021, 7:39pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/8 "2021-04-30T19:39:33Z")

</div>

Seb, that doesn’t work. Correct, wait-cluster executes, then user-script executes, works. However, if we run wait-cluster.py, Python ends and we get a command prompt back. This is correct behavior normally, but not in this case.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 30, 2021, 8:37pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/9 "2021-04-30T20:37:57Z")

</div>

Try `pvpython -i wait-cluster.py`. That will keep you in the Python interpretter after `wait-cluster.py` executes.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [April 30, 2021, 9:20pm UTC](https://discourse.paraview.org/t/pvpython-how-to-run-startup-script/6970/10 "2021-04-30T21:20:55Z")

</div>

That was the trick. Thanks Cory!
