Superbuild with custom python version crashes after running script

I have been working with the superbuild using a custom python version on windows-

When building I set these cmake variables:

  • ENABLE_python=True
  • ENABLE_python3=True
  • Python3_EXECUTABLE=…/python.exe
  • Python3_INCLUDE_DIR=…/include
  • Python3_LIBRARY=…/python39.dll

Executing scripts with the interpreter that is copied to the superbuild directory works great, and the custom modules that I wanted to install are available in pvpython. However, when I execute any script using the vtkPythonInterpreter or the paraview python shell, paraview immediately closes after finishing execution. I have found that the sys.path for pvpython and the python interpreter from my installation differ significantly:

interpreter -

pvpython -

I have also tried setting my Path and PYTHONPATH environmental variables before executing paraview with no success.