[vtkusers] Python 3 requires relative or correct absolute imports
Matthias Blaicher
matthias at blaicher.com
Mon Oct 5 08:56:40 EDT 2015
Hi,
in my quest to have a working PKGBUILD for Arch Linux with Python 3
support I've stumbled over a new issue:
> Python 3.5.0 (default, Sep 20 2015, 11:28:25)
> [GCC 5.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import vtk
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python3.5/site-packages/vtk/__init__.py", line 39, in <module>
> from .vtkCommonCore import *
> File "/usr/lib/python3.5/site-packages/vtk/vtkCommonCore.py", line 1, in <module>
> from vtkCommonCorePython import *
> ImportError: No module named 'vtkCommonCorePython'
>>>>
It's clear that this fails, since /usr/lib/python3.5/site-packages/vtk/
is not in the search path, so it cannot find
/usr/lib/python3.5/site-packages/vtk/vtkCommonCorePython.so.
This can be confirmed by adding the vtk package to the search path via
> export PYTHONPATH=/usr/lib/python3.5/site-packages/vtk
However, this should obviously work without manually defining the search
path. I propose to change the line to
> from vtk.vtkCommonCorePython import *
or
> from .vtkCommonCorePython import *
I guess the latter one is not backward compatible to python 2 except
with a _future_ import.
There is quite a list of files effected by this:
> grep -r '^from vtk[A-Za-z]\+ import' /usr/lib/python3.5/site-packages/vtk/
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersExtraction.py:from vtkFiltersExtractionPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOSQL.py:from vtkIOSQLPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOExodus.py:from vtkIOExodusPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersPython.py:from vtkFiltersPythonPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingContextOpenGL.py:from vtkRenderingContextOpenGLPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersProgrammable.py:from vtkFiltersProgrammablePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingCore.py:from vtkRenderingCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkInfovisCore.py:from vtkInfovisCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingLabel.py:from vtkRenderingLabelPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersImaging.py:from vtkFiltersImagingPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkGeovisCore.py:from vtkGeovisCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOMINC.py:from vtkIOMINCPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersGeometry.py:from vtkFiltersGeometryPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOMovie.py:from vtkIOMoviePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIONetCDF.py:from vtkIONetCDFPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingColor.py:from vtkImagingColorPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOGeometry.py:from vtkIOGeometryPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingStencil.py:from vtkImagingStencilPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkTestingRendering.py:from vtkTestingRenderingPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkViewsCore.py:from vtkViewsCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOLSDyna.py:from vtkIOLSDynaPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOAMR.py:from vtkIOAMRPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkDomainsChemistry.py:from vtkDomainsChemistryPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkParallelCore.py:from vtkParallelCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersParallel.py:from vtkFiltersParallelPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersSources.py:from vtkFiltersSourcesPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkViewsInfovis.py:from vtkViewsInfovisPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersHybrid.py:from vtkFiltersHybridPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersAMR.py:from vtkFiltersAMRPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersParallelImaging.py:from vtkFiltersParallelImagingPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOParallelXML.py:from vtkIOParallelXMLPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingAnnotation.py:from vtkRenderingAnnotationPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingCore.py:from vtkImagingCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersVerdict.py:from vtkFiltersVerdictPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOCore.py:from vtkIOCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkChartsCore.py:from vtkChartsCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingOpenGL.py:from vtkRenderingOpenGLPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingMorphological.py:from vtkImagingMorphologicalPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOXMLParser.py:from vtkIOXMLParserPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonDataModel.py:from vtkCommonDataModelPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOLegacy.py:from vtkIOLegacyPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingLOD.py:from vtkRenderingLODPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersSMP.py:from vtkFiltersSMPPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingGeneral.py:from vtkImagingGeneralPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingStatistics.py:from vtkImagingStatisticsPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOEnSight.py:from vtkIOEnSightPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersStatistics.py:from vtkFiltersStatisticsPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOPLY.py:from vtkIOPLYPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkInfovisLayout.py:from vtkInfovisLayoutPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingSources.py:from vtkImagingSourcesPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingFreeType.py:from vtkRenderingFreeTypePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingMath.py:from vtkImagingMathPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOExport.py:from vtkIOExportPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkInteractionStyle.py:from vtkInteractionStylePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOParallel.py:from vtkIOParallelPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersModeling.py:from vtkFiltersModelingPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkInteractionWidgets.py:from vtkInteractionWidgetsPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersHyperTree.py:from vtkFiltersHyperTreePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonTransforms.py:from vtkCommonTransformsPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOXML.py:from vtkIOXMLPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingImage.py:from vtkRenderingImagePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersFlowPaths.py:from vtkFiltersFlowPathsPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonComputationalGeometry.py:from vtkCommonComputationalGeometryPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkInteractionImage.py:from vtkInteractionImagePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingFourier.py:from vtkImagingFourierPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOImage.py:from vtkIOImagePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonExecutionModel.py:from vtkCommonExecutionModelPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkImagingHybrid.py:from vtkImagingHybridPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersGeneric.py:from vtkFiltersGenericPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersSelection.py:from vtkFiltersSelectionPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonMisc.py:from vtkCommonMiscPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersGeneral.py:from vtkFiltersGeneralPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonSystem.py:from vtkCommonSystemPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersCore.py:from vtkFiltersCorePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingVolume.py:from vtkRenderingVolumePython import *
> /usr/lib/python3.5/site-packages/vtk/vtkCommonColor.py:from vtkCommonColorPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOVideo.py:from vtkIOVideoPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingVolumeOpenGL.py:from vtkRenderingVolumeOpenGLPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOImport.py:from vtkIOImportPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkRenderingLIC.py:from vtkRenderingLICPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkIOInfovis.py:from vtkIOInfovisPython import *
> /usr/lib/python3.5/site-packages/vtk/vtkFiltersTexture.py:from vtkFiltersTexturePython import
Very best,
Matthias
More information about the vtkusers
mailing list