Install any python package for the ParaView binary release using pip

The ParaView binary release (from https://paraview.org/download) is great as it is an very easy way to install and use ParaView.

However it has one big limitation, is that it contains a set number of python packages without an obvious way to augment that set.

Indeed, installing python packages locally will not work unless your local python is the exact same version as the one used by ParaView. Not everyone has the possiblity to install a specific version of python on their computer just for ParaView.

But, to be fair, ParaView does not need your system python to be the same, it only needs the installed python package to be compatible with the right version of python!
And it so happens that pip does support installing package for other versions of python.

With that in mind, we can consider the local Python and pip to be just a package manager used to install packages that ParaView can use.

Here is a concrete example.

  • Download ParaView 5.12.0 binary release archive from https://paraview.org/download
  • Extract it and run ParaView
  • Help → About → Note the “Python Libary Version” : 3.10.13
  • Alternatively, run ./bin/pvpython -c "import sys; print(sys.version)"
  • Install packages (here I’m installing pytest) in a dedicated directory
mkdir /path/to/paraview_5120_python_packages
python3 -m pip  install --only-binary=:all: --python-version 3.10.13 --target paraview_5120_python_packages/  pytest pytest-cov exceptiongroup
  • Run ParaView with PYTHONPATH set correctly, you can now import pytest!
PYTHONPATH=path/to/paraview_5120_python_packages/ ./bin/pvpython
> import pytest
9 Likes

With the addition of the --venv arg to ParaView (available starting in ParaView 5.13), it becomes simpler to deploy that workflow, here is a concrete example.

  • Download ParaView 5.13.3 binary release archive from https://paraview.org/download
  • Extract it and cd to it
  • run ./bin/pvpython -m venv .venv
  • run ./bin/pvpython -c "import sys; print(sys.version)"
  • Install packages (here I’m installing pytest) in the directory right in the venv
python3 -m pip  install --only-binary=:all: --python-version 3.12.7 --target ./.venv/lib/python3.12/site-packages/ pytest pytest-cov exceptiongroup
  • Run ParaView with ./bin/paraview --venv .venv
  • Open Python Shell, you can import pytest: import pytest
2 Likes

What version? I don’t see a version 6 at that download link.

5.13.3. I’ve updated the directions in Mathieu’s latest post.