[vtkusers] Compiling VTK Python from source

ashwin .D winash12 at gmail.com
Mon Mar 12 03:18:19 EDT 2018


Ok - looks like I finally got it right !!!


 cmake ../ -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON
-DCMAKE_BUILD_TYPE=Release -DVTK_WRAP_PYTHON=ON   -DVTK_PYTHON_VERSION=3.5
-DPYTHON_EXECUTABLE:PATH=/usr/bin/python3.5
-DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.5
-DPYTHON_LIBRARY:PATH=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/
libpython3.5m.so >& cmake_log

You also need to ensure TCL is turned off - this is certainly true for VTK
8.1 onwards

It appears the file - libpython3.5m.so is the file required for linking(
please do not ask me how I got hold of that piece of information !!!!!!!!!)
but it would be nice if some of this information *does* get documented for
others who may come after me.

And did you get vtkpython compiled ? Yes I did on Ubuntu !! I also ran make
test and I got 97 % tests passed - a total of 54 tests out of 1875 passed.
I will leave it to the experts to let me know if that is significat or not.



On Mon, Mar 12, 2018 at 11:27 AM, ashwin .D <winash12 at gmail.com> wrote:

> I believe I have narrowed the cause of the error - in the output of cmake
> I get this error message -
>
> WARNING: Target "vtkpython" requests linking to directory
> "/usr/lib/python3.5".  Targets may link only to libraries.  CMake is
> dropping the item.
>
> It appears I have to link to a specific python library file in the
> /usr/lib/python3.5. But which one ?
> Under /usr/lib/python3.5 I see a directory lib-dynload and I see many .so
> files there. If somebody can give me a clue on this one I will be all  set.
>
>
>
> On Mon, Mar 12, 2018 at 6:45 AM, ashwin .D <winash12 at gmail.com> wrote:
>
>> It seems I was a bit premature in jumping to the conclusion that my VTK
>> installation was complete :-). Yes I did generate a vtkpython.exe but that
>> was with the 2.7.0 installation. When I did run this with Python3.5 I got
>> an error.
>>
>> So I went back to the build process specifically cmake and these are the
>> errors I got when I typed make -j8
>>
>>
>> This is my cmake command -
>>
>> cmake ../ -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DVTK_WRAP_PYTHON=ON -DVTK_PYTHON_VERSION=3.5 -DPYTHON_EXECUTABLE=/usr/bin/python3.5 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5 -DPYTHON_LIBRARY_PATH=/usr/lib/python3.5
>>
>>
>>
>> I presume VTK can be compiled with Python 3.5 or not ? I am not sure.
>> Apologies for the earlier over sight. This is on Ubuntu 16.04.
>>
>>
>> vtkPythonAppInit.cxx:(.text+0x97): undefined reference to `PyList_Insert'
>> CMakeFiles/vtkpython.dir/vtkPythonAppInit.cxx.o: In function `
>>
>> vtkPythonAppInitPrependPythonPath(char const*) [clone .constprop.33]':
>> vtkPythonAppInit.cxx:(.text+0x322): undefined reference to `PySys_GetObject'
>> vtkPythonAppInit.cxx:(.text+0x32f): undefined reference to `PyUnicode_FromString'
>> vtkPythonAppInit.cxx:(.text+0x33f): undefined reference to `PyList_Insert'
>> CMakeFiles/vtkpython.dir/vtkPythonAppInit.cxx.o: In function `main':
>> vtkPythonAppInit.cxx:(.text.startup+0xf9): undefined reference to `Py_DecodeLocale'
>> vtkPythonAppInit.cxx:(.text.startup+0x10f): undefined reference to `Py_SetProgramName'
>> vtkPythonAppInit.cxx:(.text.startup+0x114): undefined reference to `Py_Initialize'
>> vtkPythonAppInit.cxx:(.text.startup+0x119): undefined reference to `PyEval_InitThreads'
>> vtkPythonAppInit.cxx:(.text.startup+0x14d): undefined reference to `PySys_GetObject'
>> vtkPythonAppInit.cxx:(.text.startup+0x155): undefined reference to ` PyUnicode_EncodeFSDefault'
>> vtkPythonAppInit.cxx:(.text.startup+0x162): undefined reference to `PyBytes_AsString'
>> vtkPythonAppInit.cxx:(.text.startup+0x471): undefined reference to `Py_DecodeLocale'
>> vtkPythonAppInit.cxx:(.text.startup+0x4ad): undefined reference to `PyMem_Free'
>> vtkPythonAppInit.cxx:(.text.startup+0x4bf): undefined reference to `PyMem_Free'
>> vtkPythonAppInit.cxx:(.text.startup+0xc92): undefined reference to `Py_Main'
>> vtkPythonAppInit.cxx:(.text.startup+0xc9e): undefined reference to `PyMem_Free'
>> vtkPythonAppInit.cxx:(.text.startup+0xcc4): undefined reference to `PyMem_Free'
>> collect2: error: ld returned 1 exit status
>> Wrapping/Python/CMakeFiles/vtkpython.dir/build.make:98: recipe for target   'bin/vtkpython' failed
>> make[2]: *** [bin/vtkpython] Error 1
>> CMakeFiles/Makefile2:25907: recipe for target 'Wrapping/Python/CMakeFiles/vtkpython.dir/all' failed
>> make[1]: *** [Wrapping/Python/CMakeFiles/vtkpython.dir/all] Error 2
>> make[1]: *** Waiting for unfinished jobs....
>> [  9%] Built target vtkNetCDF
>> [ 30%] Built target VTKData
>> [ 31%] Built target vtkCommonCoreCxxTests
>> [ 32%] Built target vtkCommonDataModel
>> [ 35%] Built target vtkCommonCorePythonD
>> Makefile:138: recipe for target 'all' failed
>> make: *** [all] Error 2
>>
>>
>>
>> On Sun, Mar 11, 2018 at 8:54 AM, ashwin .D <winash12 at gmail.com> wrote:
>>
>>> I was able to get this to compile successfully and generate a
>>> vtkpython.exe. I downloaded a later version of this namely i.e. 8.1. 0 and
>>> I also needed to add one more option to the command line
>>>
>>> i.e. -DVTK_PYTHON_VERSION=3.5 while running cmake. This I believe is
>>> *required* else it defaults to the 2.7 installation.
>>>
>>>
>>>
>>> On Thu, Mar 8, 2018 at 8:02 PM, ashwin .D <winash12 at gmail.com> wrote:
>>>
>>>> The log file I sent you just now is the result of running make -j8.
>>>>
>>>> On Thu, Mar 8, 2018 at 7:58 PM, David E DeMarle <
>>>> dave.demarle at kitware.com> wrote:
>>>>
>>>>> Did you run make?
>>>>> cmake just builds makefiles/visual studio solution files or whatever.
>>>>> You still have to compile those to make the library/binraries/bindings and
>>>>> whatnot.
>>>>>
>>>>> David E DeMarle
>>>>> Kitware, Inc.
>>>>> Principal Engineer
>>>>> 21 Corporate Drive
>>>>> Clifton Park, NY 12065-8662
>>>>> Phone: 518-881-4909
>>>>>
>>>>> On Thu, Mar 8, 2018 at 6:45 AM, ashwin .D <winash12 at gmail.com> wrote:
>>>>>
>>>>>> Hello,
>>>>>>            I have VTK 7.0.0 tar file and I am trying to compile from
>>>>>> source the python wrapper for VTK. I have ccmake installed on my Ubuntu
>>>>>> 16.04 box but no matter what I try(the installation itself proceeds with no
>>>>>> errors) but I cannot find out where the python wrapper for SDK is present.
>>>>>> When I type
>>>>>>
>>>>>> python3.5  import vtk
>>>>>>
>>>>>> I get ImportError : no module named 'vtk`
>>>>>>
>>>>>> Here is how I built VTK for python using ccmake
>>>>>>
>>>>>>
>>>>>> ccmake -DCMAKE_INSTALL_PREFIX=/opt/local/vtk7.0-py3.5.0
>>>>>> -DBUILD_SHARED_LIBS:BOOL=ON-DVTK_WRAP_PYTHON:BOOL=ON
>>>>>> -DVTK_PYTHON_VERSION:STRING=3.5 -DPYTHON_EXECUTABLE:PATH=/usr/bin/python3.5
>>>>>> -DPYTHON_INCLUDE_DIR=/usr/include/python3.5
>>>>>> -DPYTHON_LIBRARY:PATH=/usr/local/lib/python3.5/ ..VTK-7.0.0
>>>>>>
>>>>>> Then a ccmake window pops up and I type ctcl - c twice and ctrl-g
>>>>>> once. But this does not do the job.
>>>>>>
>>>>>> Any suggestions will be appreciated. I intend to use VTK with Mayavi
>>>>>> eventually.
>>>>>>
>>>>>> Best regards,
>>>>>> Ashwin.
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> https://vtk.org/mailman/listinfo/vtkusers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180312/94708a17/attachment.html>


More information about the vtkusers mailing list