Adding ParaView as a dependency to a Python project

I’m building an application using the paraview.simple module. To enable CI and generally simplify things, I’d like to include ParaView (PV) as a dependency of my project (I use poetry, my dependencies are in a pyproject.toml file). I see there exists a paraview Anaconda package here, but I couldn’t find an equivalent on PyPI. Hence the question, how can I add PV as a dependency? Is it at all possible?

If not possible, what’s the best option? I can think of:

  • asking the user to install PV manually in the documentation and create the necessary symlinks in the virtual environment
  • scripting the download of PV and creation of symlinks

I’m aware I could use pvpython instead of a separate virtual environment, but that doesn’t suit my needs.

Any help would be greatly appreciated!

-Guillaume

You can use PV with a virtual-environment

1 Like

Thanks for your message! Could you elaborate a bit:

  • What do you mean exactly?
  • How do I do that? Do you have a reference?

He means that you can make a venv and tell ParaView (pvpython) to use that. ParaView is really difficult to make into a wheel at this time, so PyPI distribution isn’t really on the schedule at all.

@jourdain?

python3.10 -m venv py-env # make sure you use the same python version as your instance of paraview uses
source py-env/bin/activate
pip install <packages you need>
<paraview>/bin/pvpython script.py --venv ./py-env

Thanks @ben.boeckel & @Christos_Tsolakis for the replies. I’ll test this approach and report back if I run into issues. I also have to think a bit more about how this fits into my goal.

Hi,

 Just to make sure before spending too much time on pvpython using an extra virtual 

environment … Am I right in assuming that I can add a virtual environment without building
ParaView from scratch ? I’m actually using Paraview (5.13.0) binaries which come with python 3.10.13. (So I created my own virtual environment pvextra based on python 3.10.13, installing a few python modules: xarray, pyvista and geovista).

I’m getting this memory corruption error …

pvpython --venv /home/jmb001/.venv/pvextra my_script.py
Error message:

Blockquote

ParaView is using venv: /home/jmb001/.venv/pvextra
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1295 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1487 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1264 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1303 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1261 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1269 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1262 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1298 characters)
PyVista error in handling VTK error message:
‘WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:root:WARNING:r’ … (1261 characters)
free(): invalid pointer
error: exception occurred: Subprocess aborted

Blockquote

Thanks,
Jean-Marc

pvpython --venv /home/jmb001/.venv       /path/to/script.py  

Also side note, PyVista will install VTK inside the venv which will conflict with the one available on ParaView. So make sure you remove vtk from the venv.

Thanks Sebastien,

 Oupss!  vtk ... good point.

 Sorry to insist: :-)
 I assume adding my virtual environment without building ParaView from scratch is OK ?

Jean-Marc

yes I do that everyday.

Good. Appreciate it.