LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a .pyd file in Call library Function Node

Hi, 

 

I am looking to use a external library but have a python Package pyd file for it rather than a dll. According to a google search this should behave like a dll. When I call it through a Call Library Function Node I can see the functions that are contained in it but I get a broken run arrow saying that the library has failed to load. 

Does anybody know how I can either convert this to a dll or convince LabVIEW to accept it as a dll? 

 

 

 

image.png

0 Kudos
Message 1 of 4
(2,644 Views)

I use .pyd files quite a few times.

 

CLFN_pyd.png

My guess is that a dependency of that library is not locatable (ie. in your PATH).  I like to use the following tool to check:

 

https://github.com/lucasg/Dependencies

 

Just open your pyd file in the gui and check for errors.  

Message 2 of 4
(2,565 Views)

Hi,

 

To begin with, my problem is exactly the same as the one that has been posted on stack overflow, described here: "https://stackoverflow.com/questions/71034793/after-making-pyd-with-cython-i-only-can-call-the-pyini...", but it has no answers at all. Can you please share how do you prepare .pyd files to be used from LabVIEW? I created one by following the official Cython tutorial that can be found on that page: “https://cython.readthedocs.io/en/latest/src/quickstart/build.html”, but it didn’t work. I found the NI guide how to prepare .dll file using Visual Studio but it is not helpful in this case.

 

Kind thanks in advance

0 Kudos
Message 3 of 4
(1,908 Views)

There are many potential problems with this. A pyd file is indeed a sort of DLL but it also has runtime dependencies just as any other DLL. Typically that is at least the C runtime for the C compiler that was used to create the DLL. Depending on the setupfile that you used to create your pyd file, it invoked the according C compiler such as Microsoft Visual C, which of course needs to be installed. But each version of Visual C has its specific C runtime version that needs to be installed on any computer on which you try to load that dll/pyd file. Choosing another compiler such as MingW32 doesn't avoid that problem, it just requires you to install the according runtime library for the MingW32 version you had used.

 

Then there is the potential problem that this pyd file actually might call Python specific functions. These are provided by the PythonXX.dll file. This file is normally not installed in a way that the Windows DLL loader automatically would find it, since the Python.exe file is normally located in the same directory as that DLL and therefore will automatically link to it correctly, but for other programs, Windows won't be able to find the DLL.

 

So first problem is that you need to have the correct C Runtime library installed one every computer that you want to run this pyd file on. This C Runtime library is compiler specific and in most cases also version specific, meaning you need to install the C Runtime library version that matches the C compiler version used to create the pyd file.

 

Then you might have to help Windows to find the PythonXX.DLL file. This can happen by adding the according directory to the PATH environment variable. Some Python installers have an option to let it make this modification of your PATH environment variable at installation time, but this option is normally disabled by default as it is not needed to let Python itself run.

Rolf Kalbermatter
My Blog
Message 4 of 4
(1,894 Views)