from paraview.simple import * => ImportError: DLL load failed while importing vtkRemotingApplication

Hello Everyone,

I am considering using Paraview as an advanced 3D viewer in another software.
So I prototyped a little thing in Python and Qt5, and it works well as a standalone software (just a tiny prototype helloworld with a 3D sphere).

Now I am trying to integrate that prototype into a python plugin instead of a standalone program, but it fails to import the paraview.simple module.

So, my test case is very simple indeed: from my third party program python console, I am typing:

from paraview.simple import *

and it fails with the following message:

from paraview.simple import *
Traceback (most recent call last):
  File "C:\PROGRA~1\PARAVI~1.1\bin\Lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\PROGRA~1/QGIS32~1.2/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\PROGRA~1\PARAVI~1.1\bin\Lib\site-packages\paraview\simple.py", line 41, in <module>
    from paraview import servermanager
  File "C:\PROGRA~1/QGIS32~1.2/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\PROGRA~1\PARAVI~1.1\bin\Lib\site-packages\paraview\servermanager.py", line 60, in <module>
    from paraview.modules.vtkRemotingApplication import *
  File "C:\PROGRA~1/QGIS32~1.2/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: DLL load failed while importing vtkRemotingApplication: La procédure spécifiée est introuvable.

Is there any log I can search in to get more detailed infos?
I am considering rebuilding Paraview and adding a few messages in the init functions of vtkRemotingApplication but it would be great if there is something easier!!

Thanks in advance for any hints!

It sounds like a path problem.

To use ParaView from external program (like python shell), you should set your PYTHONPATH accordingly, and maybe your PATH (or LD_LIBRARY_PATH on linux)

1 Like

Thanks a lot for the fast anwser!

That’s what I was thinking too and, at first glance I thought the third party program (QGis) would inherit it from my Windows environment and as it works as a standalone program I thought it was weird.
Then I noticed that QGis, for some reason, actually overwrites the windows PATH and set it for its own local usage (it’s not adding its own environment, it overwrites it!?). So I was expecting a lot of modifying the QGis path env var in the QGis options, but that didn’t change anything.

As for the PYTHONPATH, it looks untouched by QGis and it’s defined as such on my machine:
pythonpath in the QGis options:

C:\PROGRA~1\PARAVI~1.1\bin\Lib;C:\PROGRA~1\PARAVI~1.1\bin\Lib\SITE-P~1\paraview;C:\PROGRA~1\PARAVI~1.1\bin\Lib\SITE-P~1\paraview;

pythonpath in my system:

C:\Program Files\ParaView 5.11.1\bin\Lib;C:\Program Files\ParaView 5.11.1\bin\Lib\site-packages

From the QGis python console:

import sys
print (sys.path)
['C:/PROGRA~1/QGIS32~1.2/apps/qgis/./python'
 'C:/Users/myUSerLogin/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python'
 'C:/Users/myUSerLogin/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins'
 'C:/PROGRA~1/QGIS32~1.2/apps/qgis/./python/plugins'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin\\Lib'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin\\Lib\\SITE-P~1\\paraview'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin\\Lib\\SITE-P~1'
 'C:\\Users\\myUSerLogin\\Documents'
 'C:\\Program Files\\QGIS 3.24.2\\bin\\python39.zip'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\DLLs'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib'
 'C:\\Program Files\\QGIS 3.24.2\\bin'
 'C:\\Users\\myUSerLogin\\AppData\\Roaming\\Python\\Python39\\site-packages'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\GDAL-3.4.2-py3.9-win-amd64.egg'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\win32'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\win32\\lib'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\Pythonwin'
 'C:/Users/myUSerLogin/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python']

The paraview site-packages & lib directories are both present in the sys.path python variable: can you see something obvious missing by any chance?

Unfortunately, I’m not expert on the Windows specificity concerning PATH and so.

Did you try to also add your root bin C:\Program Files\ParaView 5.11.1\bin ?

1 Like

Not too sure, I can’t remember. Probably not.
I am going to try that a bit later tonight, thanks! (I am in between two meetings right now ^^')

So,

C:\PROGRA~1\PARAVI~1.1\bin

was already in my system PATH, but not in the PYTHONPATH.
I added it, and …
Unfortunately, it returns the same error.

import sys
print (sys.path)
'C:/PROGRA~1/QGIS32~1.2/apps/qgis/./python'
 'C:/Users/myUSerLogin/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python'
 'C:/Users/myUSerLogin/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins'
 'C:/PROGRA~1/QGIS32~1.2/apps/qgis/./python/plugins'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin\\Lib'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin\\Lib\\SITE-P~1\\paraview'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin'
 'C:\\PROGRA~1\\PARAVI~1.1\\bin\\Lib\\SITE-P~1'
 'C:\\Users\\myUSerLogin\\Documents'
 'C:\\Program Files\\QGIS 3.24.2\\bin\\python39.zip'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\DLLs'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib'
 'C:\\Program Files\\QGIS 3.24.2\\bin'
 'C:\\Users\\myUSerLogin\\AppData\\Roaming\\Python\\Python39\\site-packages'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\GDAL-3.4.2-py3.9-win-amd64.egg'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\win32'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\win32\\lib'
 'C:\\PROGRA~1\\QGIS32~1.2\\apps\\Python39\\lib\\site-packages\\Pythonwin'
 'C:/Users/myUSerLogin/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python'
from paraview.simple import *
Traceback (most recent call last):
  File "C:\PROGRA~1\PARAVI~1.1\bin\Lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\PROGRA~1/QGIS32~1.2/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\PROGRA~1\PARAVI~1.1\bin\Lib\SITE-P~1\paraview\simple.py", line 41, in <module>
    from paraview import servermanager
  File "C:\PROGRA~1/QGIS32~1.2/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\PROGRA~1\PARAVI~1.1\bin\Lib\SITE-P~1\paraview\servermanager.py", line 60, in <module>
    from paraview.modules.vtkRemotingApplication import *
  File "C:\PROGRA~1/QGIS32~1.2/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: DLL load failed while importing vtkRemotingApplication: La procédure spécifiée est introuvable.

So I’m not sure what happen.

To investigate look for vtkRemotingApplication*.dll and ensure that any result is in your PATH

Apparently it won’t work either.
I also found an old page where the user had a similar issue and could make it work by changing the current directory to c:/program files/paraview/bin, but that doesn’t work either for me.
I also tried to change the current directory to C:/PROGRA~1/PARAVI~1.1/bin/Lib/SITE-P~1/paraview/modules since there is a vtkRemotingApplication-pv5.11.dll there too, but that doesn’t work any better.

On the other hand, I noticed Paraview 5.11.1 is using python 3.9.13, whereas my QGis is using python 3.9.5.
Do you reckon it could be some compatibility issue?
Maybe I could try to build Paraview with the QGis python version directly?

Building ParaView with same python than QGis is at least a good idea, if not even required :slight_smile:

But I can not affirm that it will solve your bug …

Can you try to

from paraview.simple import *

in a simple python interpreter ? So you can verify which env var are needed by python to correctly import pv. Then we may try to port that to QGis ?

1 Like

Thanks! :slight_smile:
I am currently configuring the cmake options, and then we will see what happen

As for the simple python interpreter (the one from QGis but launched as a standalone program, not from the QGis terminal), it works indeed, and it also works from pvpython from Paraview. So it only doesn’t work when launched from QGis, which is a pity, since that’s what I need to do :smiley:
I tried to copy the import sys / print(sys.path) paths pvpython to my qgis environment but that didn’t do anything either, apparently.


For future references:

Ok!

pvpython is a simple interpreter with “builtin configuration” to find paraview module without environment tweak, so it is pretty expected that it worked :stuck_out_tongue:

I think that it is a matter of finding DLLs, so modifying PYTHONPATH or sys.path from python directly should not impact at this point (I mean, now that the simple.py module is found)

As for pvpython, I guess it’s nice to see something working from time to time :smiley:
But seriously, I used pvpython to get a working sys.path and then copying it all to my qgis environment. But as I said, it didn’t work.

How long is the Paraview allbuild supposed to last? A few tens of minutes, a few hours? (obviously it depends on the PC but on a regular i7 8th generation, what should I expect? Hours?)

edit: Oh, it’s already halfway there, apparently

For some reason, VS 2019 fails with a lack of heap space (?!) on the commonCore vtkSMP header with vtk_smp_implementation_type set to set to stdthread in cmake, so I am now trying to compile paraview with that parameter being set to “sequential”

Edit: same VS heap space error, now that’s strange.

Edit 2 : now updating VS :smile:
If that doesn’t work, I will try with VS 2022

\o/

(edit: I am going to sum up the things to do a bit later)

Hello, I found the exact same problem, in my case, I was trying to pair Paraview with jupyter notebook and (once the environmental variables were set) copying the content of the DLLs folder from the Paraview installation directory (C:\Program Files\ParaView 5.11.1\bin\DLLs) to the DLLs folder on the conda environment (C:\Users\GL504GS\.conda\envs\env_name\DLLs) did the trick.

Just sharing so that others have an easier time overcoming this minor issue.

1 Like

Thanks Bruno, that could be a nice solution too in case it’s too annoying to recompile Paraview. I will have to test it in QGIS too, I don’t know if it would disturb it? Anyway, thanks for sharing your solution as well!