Hi all,
I am trying to make a portable python vtk reader with pyInstaller. All tested computers have the same OS (windows 7 SP1) but on most of them it doesn’t work.
Here is a test script named “VTK-TEST.py” (a simple vtk window containing a single slider):
#!/usr/bin/env python
import vtk
print(“starting…”)
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(600,600)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
sliderRepresent=vtk.vtkSliderRepresentation2D()
sliderRepresent.SetMinimumValue(0.0)
sliderRepresent.SetMaximumValue(1.0)
sliderRepresent.GetPoint1Coordinate().SetCoordinateSystemToDisplay()
sliderRepresent.GetPoint1Coordinate().SetValue(40,70)
sliderRepresent.GetPoint2Coordinate().SetCoordinateSystemToDisplay()
sliderRepresent.GetPoint2Coordinate().SetValue(440,470)
sliderWidget=vtk.vtkSliderWidget()
sliderWidget.SetInteractor(iren)
sliderWidget.SetRepresentation(sliderRepresent)
sliderWidget.SetAnimationModeToAnimate()
sliderWidget.EnabledOn()
iren.Initialize()
renWin.Render()
iren.Start()
Using the following command to make a pyInstaller distribution:
pyInstaller VTK-TEST.py
it produces a folder containing all kind of vtk and python related files and one .exe executable.
Putting the distribution on an USB key, it works on some computers but not others (all with same OS) and I am trying to understand why.
When the produced distribution doesn’t work, launching the .exe results in the following error:
ModuleNotFoundError: no module named ‘vtkCommonKitPython’
(despite the fact that a file named vtkCommonKitPython.pyd is included in the distribution)
I tried edditing the .spec file line: hiddenimports=[‘vtk’], to be sure all vtk dependencies are exported, but using the dist built by the following command, it still doesn’t change anything.
pyInstaller VTK-TEST.spec
I’ve tried doing the same for other simple scripts and tkinter scripts, those distributions work on all our computers as long as vtk is not involved.
I am guessing vtk distributions work or not depending on softwares allready installed on the computer, but I cannot find a common denominator. I would like the distribution to work without having to install anything as much as possible.
I suppose I am missing some tags in the .spec file that would make the vtk distribution work, I ll be grateful if you can help me.
Thanks,
edit I shall specify that I use python 3.7, vtk 8.1.2 and pyInstaller 3.4