vtk module not found while exporting as vtkjs

Hi,

I’m trying to export a scene as vtkjs on my linux machine.
I have created a new virtual environment using:
python -m venv env

Into my env/bin/activate script I have added these paths so that python finds the paraview library:

export PATH="/opt/paraview/bin/:$PATH"
export PYTHONPATH="/opt/paraview/lib/:/opt/paraview/lib/python3.11/site-packages/:${PYTHONPATH}"
export LD_LIBRARY_PATH="/opt/paraview/lib/:${LD_LIBRARY_PATH}"

Now I enter my environment source env/bin/activate and execute the following python script:

from paraview.simple import *

renderView1 = CreateRenderView()

SetActiveView(renderView1)

wavelet1 = Wavelet()
wavelet1Display = Show()
wavelet1Display.SetRepresentationType('Surface')

ColorBy(wavelet1Display, 'RTData')
tf = GetColorTransferFunction('RTData')
tf.ApplyPreset('Cold and Hot', True)

ExportView("./test.vtkjs")
Interact()

I get the following errors from calling ExportView:

(   1.635s) [paraview        ]vtkJSONSceneExporter.cx:683    ERR| vtkPVWebExporter (0x63f571c93430): Cannot rename temporary file.
(   1.650s) [paraview        ]   vtkPVWebExporter.cxx:66    WARN| Failed to import vtk.web.vtkjs_helper module.
Traceback (most recent call last):
  File "//lib/python3.11/site-packages/vtk.py", line 32, in <module>
    from vtkmodules.vtkViewsInfovis import *
ModuleNotFoundError: No module named 'vtkmodules.vtkViewsInfovis'

Can someone reproduce these errors? It seems like paraview chooses at one point to use the vtk library that is installed locally and not the one which ships with paraview itself. Using the paraview gui the export works fine.

I am using paraview version 5.12.0 and python version 3.11.8.

When using a venv, its packages will be preferred to the interpreter’s “builtin” modules. Since ParaView’s package ships the interpreter, everything that comes with it is of lower precedence than a venv, so any venv with ParaView cannot have vtk installed separately.