[vtkusers] Python wrapping

David Gobbi david.gobbi at gmail.com
Sun Nov 2 16:52:27 EST 2014


Hi Gib,

Yes, the .pyd files should be in the PYTHONPATH and the DLLs
should be in the PATH.  That's all that should be needed.

My best guess is that it is failing to load vtkRenderingPython.pyd
itself, and it you hadn't specifically told me that both your python
and your VTK are 64-bit, my guess would be that it was trying to
load a 64-bit .pyd file into a 32-bit python.

Try to see if you can load the .pyd files directly, by doing this in python:

  import vtkCommonPython

When that fails, it should provide a more meaningful error message.
In any case, it's always best to start testing with the module that has
the fewest dependencies (i.e. Common) and then work up from there.

The vtk*PythonD.dll files have all the code that actually translates
python method calls into VTK C++ method calls.  But they aren't
python modules (i.e. they have no python "init" method).  They are,
in essence, the back-end of the wrappers while the vtk*Python.pyd
files are the front-end.

 - David




On Sun, Nov 2, 2014 at 1:51 PM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:

>  Hi David,
>
> Thanks for that clarification.  I don't know much about Python, and less
> about Python wrapping in VTK.
>
> I have no idea why the simple example program fails.  The code is:
>  http://www.vtk.org/Wiki/VTK/Examples/Python/Visualization/ProgGlyph
> with the first line changed (or removed - it makes no difference).
>
> PYTHONPATH includes C:\vtk-vs10-x64\lib\site-packages\vtk, and all the
> .pyd files are there.
>
> The first entry in PATH is C:\vtk-vs10-x64\bin.  Do I need any other VTK
> directories in the path?
>
> In the error message, repeated below, can you tell me for which DLL does
> the DLL load fail?
>
> D:\testing\VTK\Superquadric>vtkpython superquadric.py
> Traceback (most recent call last):
>   File "superquadric.py", line 3, in <module>  import vtk
>   File "C:\VTK-VS10-x64\lib\site-packages\vtk\__init__.py", line 63, in
> <module> __helper.refine_import_err('rendering', 'vtkRenderingPython', exc)
>   File "C:\VTK-VS10-x64\lib\site-packages\vtk\__helper.py", line 32, in
> refine_import_err raise LinkError, str(exc)
> vtk.__helper.LinkError: DLL load failed: %1 is not a valid Win32
> application.
>
> Both python27 and VTK are 64-bit.
>
> By the way, what are the vtk*PythonD.dll files?
>
> Thanks
> Gib
>  ------------------------------
> *From:* David Gobbi [david.gobbi at gmail.com]
> *Sent:* Monday, 3 November 2014 2:18 a.m.
>
> *To:* Gib Bogle
> *Cc:* vtkusers at vtk.org
> *Subject:* Re: [vtkusers] Python wrapping
>
>   Hi Gib,
>
>  The vtk*Python.pyd files are the DLLs that you are looking for.  See
> here:
> https://docs.python.org/2/faq/windows.html#is-a-pyd-file-the-same-as-a-dll
>
>   - David
>
> On Sun, Nov 2, 2014 at 12:09 AM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
>
>>  Hi David,
>>
>> All the .pyd files are where they should be, and all the vtk*PythonD.dll
>> files are where they should be, in C:\vtk-vs10-x64\bin, which is in the
>> PATH.  The point of my question was that the VTK release build did not
>> create any vtk*Python.dll files, although it did create the .lib files.
>> Correct me if I'm wrong, but I think that vtkpython is looking for the
>> missing DLL files - specifically, for vtkRenderingPython.dll.  Am I wrong
>> in thinking that they should have been built?
>>
>> Gib
>>  ------------------------------
>> *From:* David Gobbi [david.gobbi at gmail.com]
>> *Sent:* Sunday, 2 November 2014 4:11 p.m.
>> *To:* Gib Bogle
>> *Cc:* vtkusers at vtk.org
>> *Subject:* Re: [vtkusers] Python wrapping
>>
>>    Hi Gib,
>>
>>  The python modules are called "vtk*Python.pyd" on Windows.
>> On your system, I'm guessing that they should be in this directory:
>> c:\VTK-VS10-x64\lib\site-packages\vtk
>>
>>  And, in order for the modules to be loaded, all of the VTK DLLs
>> must also be in your PATH.  Either that, or you can copy them all
>> into c:\VTK-VS10-x64\lib\site-packages\vtk so that the .pyd files
>> will be able to find them there.
>>
>>  The vtk*PythonD.dll files are not python modules, they are support
>> libraries that are needed by the python modules.
>>
>>   - David
>>
>>
>>
>> On Sat, Nov 1, 2014 at 8:54 PM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
>>
>>>  I just rebuilt VTK-5.10.1 64-bit on Windows with VTK_WRAP_PYTHON ON.
>>> The build completed without errors.  I do not understand why I have 14 .lib
>>> and .dll files named vtk*PythonD.dll and vtk*PythonD.lib, and 14 .lib files
>>> named vtk*Python.lib, but no vtk*Python.dll.  This causes my attempt to run
>>> a VTK-Python example to fail like this:
>>>
>>> D:\testing\VTK\Superquadric>vtkpython superquadric.py
>>> Traceback (most recent call last):
>>>   File "superquadric.py", line 1, in <module>  import vtk
>>>   File "c:\VTK-VS10-x64\lib\site-packages\vtk\__init__.py", line 63, in
>>> <module>  __helper.refine_import_err('rendering', 'vtkRenderingPython', exc)
>>>   File "c:\VTK-VS10-x64\lib\site-packages\vtk\__helper.py", line 32, in
>>> refine_import_err raise LinkError, str(exc)
>>> vtk.__helper.LinkError: DLL load failed: %1 is not a valid Win32
>>> application.
>>>
>>> I see that somebody was asking exactly the same question back in
>>> October, 2010, but there was no answer.
>>>
>>> Any suggestions?
>>>
>>> Thanks
>>> Gib
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141102/a0e59dd2/attachment.html>


More information about the vtkusers mailing list