[vtkusers] Cannot build vtk for python3 on Ubuntu 16.04

David Gobbi david.gobbi at gmail.com
Thu Dec 21 12:41:27 EST 2017


Hi Charles,

Try running 'vtkpython' from your build tree (i.e. perhaps the build was
fine, and it was just the "install" that put the python modules in the
wrong place).

For troubleshooting, use "find" to locate vtkCommonCorePython.so and
vtkCommonCore.py and make sure they're in python's path:

e.g. cd to build tree and
find . -name vtkCommonCorePython.so
find . -name vtkCommonCore.py

Then do the same in your install prefix to find out where "make install"
put them.  You might have to copy them to lib/python3.5/site-packages, or
set your PYTHONPATH before running vtkpython.

It's odd that you say you can use it from the system's python2.7.
Obviously, binary modules built for python3 will not work with python2, but
when you run 'vtkpython' it clearly reports that VTK was built against
python3.  I have to ask, are you sure that the "vtk" that you import from
python2 is the one that you just built?  Because it seems fishy to me.  Be
sure to do a "print(vtk.__file__)" after you import vtk, so that you know
where the module came from.

 - David



On Thu, Dec 21, 2017 at 3:49 AM, Charles Kind <charles.kind at bristol.ac.uk>
wrote:

> I am running ubuntu 16.04. I build vtk with VTK_PYTHON_VERSION=3 and
> VTK_WRAP_PYTHON=ON. Once built and installed it only runs from the system
> Python 2.7.12. Even if I run vtkpython I get:
>
> *******@********:~/Downloads/a/vtkBuild$ vtkpython
> vtk version 8.0.1
> Python 3.5.2 (default, Nov 23 2017, 16:37:01)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import vtk
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named 'vtk'
>
> Help!!
>
> I do have Enthought Canopy on the same system, running VTK from python 3.5,
> but not running when I do the ccmake, make and install for vtk8.0.1. Could
> this be the problem, I am a little fearful of removing it right now as I am
> producing work for an imminent paper and need my code working.
>
> Thanks in advance for any help.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vtk.org/pipermail/vtkusers/attachments/20171221/b4d10f4f/attachment.html>


More information about the vtkusers mailing list