trame: cannot run paraview example

I had a look at the trame tutorials, and they all work, except the paraview example:

I get this error and I do not know what to do with it:
$ pvpython 05_paraview/StateLoader.py --venv .pvenv --data ./data/pv-state.pvsm

Traceback (most recent call last):
File “Codes/trame/trame-tutorial/05_paraview/StateLoader.py”, line 5, in
from trame.html import vuetify, paraview
File “/usr/local/lib/python3.9/dist-packages/trame/html/paraview/init.py”, line 1, in
from trame.html.vtk.common import (
File “/usr/local/lib/python3.9/dist-packages/trame/html/vtk/init.py”, line 21, in
use_module(VTK)
File “/usr/local/lib/python3.9/dist-packages/trame/html/vtk/common.py”, line 11, in use_module
_app.enable_module(m)
AttributeError: ‘App’ object has no attribute ‘enable_module’

I guess there is some paraview functionality missing? I’ve installed paraview superbuild from github:

$ paraview --version
paraview version 5.10.1-799-gb5dd20f80e

in the environment directory , there are references to enable_module:

~/Codes/trame/trame-tutorial/.pvenv/lib/python3.9$ grep -niIr 'enable_module' *


site-packages/trame/internal/app/app.py:104:def enable_module(module):
site-packages/trame/internal/app/app.py:111:    _app.enable_module(module)
site-packages/trame/html/widgets/__init__.py:7:_app.enable_module(Widgets)
site-packages/trame/html/simput/__init__.py:8:_app.enable_module(SimPut)
site-packages/trame/html/vega/__init__.py:9:_app.enable_module(VegaEmbed)
site-packages/trame/html/matplotlib/__init__.py:18:_app.enable_module(module)
site-packages/trame/html/plotly/__init__.py:14:_app.enable_module(Plotly)
site-packages/trame/html/markdown/__init__.py:8:_app.enable_module(Markdown)
site-packages/trame/html/xai/__init__.py:7:_app.enable_module(XAI)
site-packages/trame/html/vtk/common.py:12:    _app.enable_module(m)
site-packages/trame/html/deckgl/__init__.py:8:_app.enable_module(Deck)
site-packages/trame/html/observer/__init__.py:10:_app.enable_module(module)
site-packages/trame/html/router/__init__.py:7:_app.enable_module(Router)
site-packages/pywebvue/core.py:125:    def enable_module(self, module, **kwargs):
site-packages/pywebvue/core.py:150:        print("enableModule is deprecated, you should use 'enable_module' instead.")
site-packages/pywebvue/core.py:151:        self.enable_module(module, **kwargs)

I just tried the following and it is working for me.

  1. Download ParaView 5.10.1 from https://www.paraview.org/download/
  2. Run the following command lines
python3.9 -m venv pv_venv
source ./pv_venv/bin/activate
pip install -U pip
pip install trame
git clone https://github.com/Kitware/trame.git
/Applications/ParaView-5.10.1.app/Contents/bin/pvpython ./trame/examples/ParaView/StateViewer/app.py --venv ./pv_venv --data /.../diskout.pvsm

The following also worked

export PV_VENV=$PWD/pv_venv
/Applications/ParaView-5.10.1.app/Contents/bin/pvpython ./trame/examples/ParaView/StateViewer/app.py --data /.../diskout.pvsm

Thanks, using the paraview 5.10.1 package works. Actually, this example also works with my superbuild version.
However, the paraview example from the trame tutorial is not working for either
With the precompiled paraview, I get this:

~/Codes/paraview/ParaView-5.10.1-MPI-Linux-Python3.9-x86_64/bin/pvpython 05_paraview/StateLoader.py --venv ./pv_venv --data ./data/pv-state.pvsm                                              
Traceback (most recent call last):
File "/home/nijso/Codes/trame/trame-tutorial/05_paraview/StateLoader.py", line 4, in <module>
from trame import get_cli_parser
ImportError: cannot import name 'get_cli_parser' from 'trame' (unknown location)

I guess you found an API change that was not updated in the tutorial repo… :wink:

I’ll fix the tutorial file… thx

Ok the reason was that I was using a local venv import as it was not available from ParaView at the time of the tutorial. To make the tutorial works you need to be inside that directory.

Still updating the tutorial code to import the now available venv helper directly from ParaView…