KitwareMedical / VTKPythonPackage

A setup script to generate VTK Python Wheels
https://vtkpythonpackage.readthedocs.io
BSD 3-Clause "New" or "Revised" License
34 stars 15 forks source link

ImportError from wheel installation #38

Open arokem opened 4 years ago

arokem commented 4 years ago

Hello - thank you so much for the energy that you are investing in providing a wheel installation for VTK.

I have successfully installed the software, but am running into errors on import.

When installing from conda, I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/srv/conda/envs/notebook/lib/python3.7/site-packages/vtkmodules/vtkRenderingOpenGL2.py in <module>
      4     # use relative import for installed modules
----> 5     from .vtkRenderingOpenGL2Python import *
      6 except ImportError:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-7c7f66f02cd3> in <module>
----> 1 import vtk

/srv/conda/envs/notebook/lib/python3.7/site-packages/vtk.py in <module>
     30     all_spec = importlib.util.find_spec('vtkmodules.all')
     31     all_m = importlib.util.module_from_spec(all_spec)
---> 32     all_spec.loader.exec_module(all_m)
     33 
     34     # import vtkmodules

/srv/conda/envs/notebook/lib/python3.7/site-packages/vtkmodules/all.py in <module>
     31 from .vtkIOXMLParser import *
     32 from .vtkDomainsChemistry import *
---> 33 from .vtkRenderingOpenGL2 import *
     34 from .vtkDomainsChemistryOpenGL2 import *
     35 from .vtkIOXML import *

/srv/conda/envs/notebook/lib/python3.7/site-packages/vtkmodules/vtkRenderingOpenGL2.py in <module>
      7     # during build and testing, the modules will be elsewhere,
      8     # e.g. in lib directory or Release/Debug config directories
----> 9     from vtkRenderingOpenGL2Python import *

ModuleNotFoundError: No module named 'vtkRenderingOpenGL2Python'

When installing with pip, I instead get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/srv/conda/envs/notebook/lib/python3.7/site-packages/vtk/vtkOpenGLKit.py in <module>
      4     # use relative import for installed modules
----> 5     from .vtkOpenGLKitPython import *
      6 except ImportError:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-7c7f66f02cd3> in <module>
----> 1 import vtk

/srv/conda/envs/notebook/lib/python3.7/site-packages/vtk/__init__.py in <module>
     10 from .vtkRenderingKit import *
     11 from .vtkIOKit import *
---> 12 from .vtkOpenGLKit import *
     13 from .vtkParallelKit import *
     14 from .vtkWrappingKit import *

/srv/conda/envs/notebook/lib/python3.7/site-packages/vtk/vtkOpenGLKit.py in <module>
      7     # during build and testing, the modules will be elsewhere,
      8     # e.g. in lib directory or Release/Debug config directories
----> 9     from vtkOpenGLKitPython import *

ModuleNotFoundError: No module named 'vtkOpenGLKitPython'

Note also that this is happening on a headless system (through a Jupyter notebook, running on a JupyterHub installed on EKS), which may be pertinent information.

Thanks!

jcfr commented 4 years ago

Thanks for the feedback, we are currently working on integrating the python wheel generation as part of the VTK regular build process (see https://gitlab.kitware.com/vtk/vtk/merge_requests/5543), once this is complete, wheel for the latest version of VTK will be available.

This means that will not put effort in fixing the existing wheels.

The error you report makes sense, the VTK wheel were not built with osmesa or egl and currently require X. See https://kitware.github.io/paraview-docs/latest/cxx/Offscreen.html

thewtex commented 4 years ago

CC: @demarle @mathstuf

mathstuf commented 4 years ago

I suspect the root cause here is that the wheel is built on a pre-GLVND machine (which I highly suspect manylinux1 is), but run on a machine with only GLVND libraries. You'll need to install some compat package to get libGL.so.1 on your distribution (it makes zero sense for it to go into Python packages as it is different from machine to machine depending on graphics drivers).

mathstuf commented 4 years ago

Note that VTK's built-in wheel build will not change this fact (except that VTK now really wants to use GLVND if it is available).