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!

There are three solutions, we recommen uv.

uv + venv solution

And it so happens that uv support natively installing package in any virtual environement, and ParaView is able to generate a venv!

Here is how to do it with any version of ParaView >= 5.13.3

  • install uv
  • Download ParaView binary release archive from https://paraview.org/download
  • Extract it and cd into it.
  • ./bin/pvpython -m venv ./.venv
  • VIRTUAL_ENV=./.venv/ uv pip install pytest pytest-cov exceptiongroup
  • Run ParaView with ./bin/paraview --venv .venv
  • Open Python Shell, you can import pytest: import pytest

pip + venv solution

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

pip only solution

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.

  • install any version of Python with pip
  • 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
10 Likes

venv solution added to original post

3 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.

When I tried this on Win11, the workflow remains almost the same, except that

--target ./.venv/lib/python3.10/site-packages/

is changed to

--target ./.venv/lib/site-packages/

to make it work on my machine.

2 Likes

2 posts were split to a new topic: How to install python packages

It is now even simpler to do thanks to uv ! I’ve update my post to reflect that. No need to recover the version of python, uv handles it for you.

With ParaView 6.0.0, I encountered some issues creating venv:

C:\Program Files\ParaView 6.0.0\bin>pvpython -m venv .venv
WRN - The configuration file has not been found, using default parameters.
Error: Command '['C:\\Program Files\\ParaView 6.0.0\\bin\\.venv\\Scripts\\pvpython.exe', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

While the warning is reported here: pvpython/pvbatch on Windows starts up and reports warning “WRN - The configuration file has not been found, using default parameters.” (#23028) · Issue · paraview/paraview, I do not see a solution to the error here. Does anyone have similar issues?

I did see this but the venv seems to be working anyway. In any case this is tangential to the topic here and should be reported here: https://gitlab.kitware.com/paraview/paraview/-/issues

Hi,

Following solution 1) uv+venv above I get this error right off the bat:

cd /U2/PARAVIEW/6.0.1/ParaView-6.0.1-MPI-Linux-Python3.12-x86_64

./bin/pvpython -m venv ./.venv

Error: Command ‘[’/U2/PARAVIEW/6.0.1/ParaView-6.0.1-MPI-Linux-Python3.12-x86_64/.venv/bin/pvpython-real’, ‘-m’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1.

My system info:

cat /etc/os-release
PRETTY_NAME=“Ubuntu 22.04.5 LTS”
NAME=“Ubuntu”
VERSION_ID=“22.04”
VERSION=“22.04.5 LTS (Jammy Jellyfish)”

uv --version
uv 0.8.15

Any suggestions ? It did work in the past with ParaView 5.13. following this link:https://www.kitware.com/using-python-virtual-environments-in-paraview-5-13-0/ . This approach which resembles solution 2) pip+venv is not using pvpython but system python …

I also tried this recipe recently without success:

uv venv --python 3.12
source .venv/bin/activate
uv pip install xarray cftime cfgrib zarr h5netcdf “numpy==1.26.4” “pandas==2.0.3” “netcdf4==1.6.5”
deactivate

from this post https://www.kitware.com/bridging-data-and-visualization-interactive-scientific-exploration-with-vtk-xarray-interoperability/

and got the xarray import error from loading the Plugin.

Based on this issue here:
https://gitlab.kitware.com/paraview/paraview/-/issues/23087
it seems like a hot topic but I’m not sure if this issue is considered solved or not?

Thanks,

Jean-Marc

 returned non-zero exit status 1.

The error is there, but the venv is working, just use it?