# Adding an output option to pvpython to show necessary environment variables for importing ParaView into python

**URL:** https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619
**Category:** Development
**Tags:** python
**Created:** [March 13, 2023, 7:16pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619 "2023-03-13T19:16:35Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [March 13, 2023, 7:16pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/1 "2023-03-13T19:16:35Z")

</div>

Hi,

I’m working on some testing functionality for code that does some ParaView processing through Python. This is for a ParaView install from the download page and not a ParaView that I built myself. I’m not sure this matters though.

What I’m wondering is how feasible it would be to add a command line option to `pvpython` that would print out the necessary environment variables (e.g. PYTHONPATH, LD\_LIBRARY\_PATH, and any others that are needed) that I’d need to set while running python so that I could import paraview into that python session. It may also be useful to include which Python version should be used as well.

Thoughts?

Thanks,  
Andy

---

<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: [March 18, 2023, 12:04am UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/2 "2023-03-18T00:04:23Z")

</div>

Andy,

That should be possible I would think.

As a workaround until that feature is added, you can get `PYTHONPATH` with

```auto
import sys
':'.join(sys.path)

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 23, 2023, 8:10pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/3 "2023-04-23T20:10:56Z")

</div>

Just `PYTHONPATH` should be necessary (for our binaries, probably Spack too, as rpaths are set up properly in these places). We could probably add it to `paraview-config` as a `--python` flag or something.

Please file an issue to track this.

---

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [April 24, 2023, 2:00pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/4 "2023-04-24T14:00:14Z")

</div>

Maybe I’m doing something wrong here but I tried running pvpython from PV 5.11 and adding the sys.path values from that into a regular Python3 session. I wasn’t able to import paraview when I added those pvpython sys.path values to the Python3 sys.path list.

Did I do something wrong?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 24, 2023, 2:05pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/5 "2023-04-24T14:05:43Z")

</div>

Does Python have any relevant error messages? Does it even find `paraview/ __init__.py` or does it fail finding the compiled bits? If the latter, `LD_DEBUG=libs` could help see where it is searching.

---

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [April 24, 2023, 2:41pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/6 "2023-04-24T14:41:18Z")

</div>

When I run pvpython from PV 5.11.1 on my RHEL8 machine I have the following output from sys.path:  
‘’’

> > > sys.path  
> > > [‘’, ‘/home/acbauer/Code/ParaView/ParaView-5.11.1-MPI-Linux-Python3.9-x86\_64/lib/python39.zip’, ‘/home/acbauer/Code/ParaView/ParaView-5.11.1-MPI-Linux-Python3.9-x86\_64/lib/python3.9’, ‘/home/acbauer/Code/ParaView/ParaView-5.11.1-MPI-Linux-Python3.9-x86\_64/lib/python3.9/lib-dynload’, ‘/home/acbauer/Code/ParaView/ParaView-5.11.1-MPI-Linux-Python3.9-x86\_64/lib/python3.9/site-packages’]  
> > > ‘’’

The error I’m getting is:

> from .modules import vtkRemotingCore  
> ImportError: /home/acbauer/Code/ParaView/ParaView-5.11.1-MPI-Linux-Python3.9-x86\_64/lib/python3.9/site-packages/paraview/modules/…/…/…/…/libvtkWrappingPythonCore3.9-pv5.11.so.1: undefined symbol: PyObject\_CheckBuffer
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “”, line 1, in   
> File “/home/acbauer/Code/ParaView/ParaView-5.11.1-MPI-Linux-Python3.9-x86\_64/lib/python3.9/site-packages/paraview/ **init**.py”, line 262, in   
> import \_paraview\_modules\_static  
> ModuleNotFoundError: No module named ‘\_paraview\_modules\_static’

The full error message I’m seeing is in the attached file. Is this working for others by just modifying their `sys.path` ?  
[python3\_import\_paraview](https://discourse.paraview.org/uploads/short-url/vzBLZxb4jCqBueHV7MOTfBsVBS9) (119.2 KB)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 24, 2023, 5:19pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/7 "2023-04-24T17:19:41Z")

</div>

It seems like the Python interpreter is not properly loading `libpython` symbols such that modules can use them? What interpreter are you using?

---

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [April 25, 2023, 12:00pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/8 "2023-04-25T12:00:27Z")

</div>

This is with the system installed version of Python3 and the downloaded installer from ParaView v5.11.1:

```auto
[acbauer@dsrclxerd5621m ~]$ uname -a
Linux dsrclxerd5621m.localdomain 4.18.0-425.19.2.el8_7.x86_64 #1 SMP Fri Mar 17 01:52:38 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
[acbauer@dsrclxerd5621m ~]$ which python3
/usr/bin/python3
[acbauer@dsrclxerd5621m ~]$ python3 --version
Python 3.6.8

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 25, 2023, 12:29pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/9 "2023-04-25T12:29:18Z")

</div>

> [@Andy\_Bauer](#):
>
> ```auto
> $ python3 --version
> Python 3.6.8
> 
> ```

This is not going to be able to load Python 3.9 modules (which is what the package is built with). Hence the undefined symbol (if it did have all the symbols, it would likely have crashed later because Python doesn’t keep the ABI stable enough to do that).

---

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [April 25, 2023, 12:37pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/10 "2023-04-25T12:37:32Z")

</div>

Got it. Thanks for tracking that down. I suppose then maybe some other useful information to be made available would be what version or versions of Python can be used. So I’m thinking something like:

```auto
$ pvpython --getsysteminformation
PYTHONPATH=['a', 'b']
required Python version = 3.9

```

I’m sure you’ll come up with better command line arguments and formatting but hopefully you get the general idea.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 25, 2023, 3:14pm UTC](https://discourse.paraview.org/t/adding-an-output-option-to-pvpython-to-show-necessary-environment-variables-for-importing-paraview-into-python/11619/11 "2023-04-25T15:14:05Z")

</div>

How about this?

[https://gitlab.kitware.com/paraview/paraview/-/merge\_requests/6304](https://gitlab.kitware.com/paraview/paraview/-/merge_requests/6304)
