[vtkusers] Compiling VTK Python from source
David Gobbi
david.gobbi at gmail.com
Mon Mar 12 10:47:19 EDT 2018
Hi Ashwin,
The PYTHON_LIBRARY_PATH needs to point to a library, rather than a
directory. For example,
-DPYTHON_LIBRARY_PATH=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/
libpython3.5m.so
Or possibly
-DPYTHON_LIBRARY_PATH=/usr/lib64/libpython3.5m.so
The location will vary between linux distros.
- David
On Sun, Mar 11, 2018 at 7:15 PM, 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 <(518)%20881-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.
>>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180312/17e83a1e/attachment.html>
More information about the vtkusers
mailing list