From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-20-2020 08:04 AM
I have a Python routine (3.7) that I use to capture a picture with an 10 GigE camera. The routine does all of the camera configuration operations, takes the picture and then converts the picture into a 2D array of 16 bit integers which it returns. If I run the Python routine outside of LabVIEW, it's fine. If I call it directly from LabVIEW, the camera isn't found and subsequently no picture is taken etc.. If I comment out all of the camera specific code in the Python routine and simulate the picture with a 2D array of random numbers, the routine works when called from LabVIEW. Any ideas why the code when called from LabVIEW doesn't work but when called directly does? I've attached a image of the code. There's nothing to it.
03-22-2020 09:10 PM
It probably has to do with the paths in the python code being wrong when called by the LabVIEW program. (Can't be sure you didn't show that part!)
If the dependencies in the python code are suddenly looking in the path of the LabVIEW caller then they are probably wrong and your python code fails. Add some logging in your python code to note where it thinks its located when called normally and from the LabVIEW vi, then adjust paths accordingly.
03-23-2020 09:12 AM
It doesn't appear that the paths are the problem. When running from labview, labview adds to the paths but the other entries are consistent with those running outside of labview. However, it appears that when launching the Python code from labview, the python code is executed twice. The first time the Python code runs, it appears to be fine. The second time it fails to find the camera. I can begin to understand that if the camera hasn't had time to reinitialize after the first call, but why is it being called twice?
The "debug" information I added to the Python code generate the text log below. Why is it running twice?
just started
system paths D:\Users\jg\Temp
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface\.\
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\python37.zip
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\Lib
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\DLLs
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\lib\site-packages
just got system
just got camera list
just got number of cameras 1
about to begin acquisition
about to get image
just got image
getting image data
just got image data, rows 200 cols 2000
just about to save the image data
just saved the image data
just copied image data
about to release image
just started
system paths D:\Users\jg\Temp
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface\.\
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\python37.zip
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\Lib
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\DLLs
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\lib\site-packages
just got system
just got camera list
just got number of cameras 0
03-23-2020 09:35 AM
I am calling a Python script (3.7) from LabVIEW that is used to capture an image from a 10GigE camera. They Python script creates a debug text file that I've been using to try to figure out why it isn't working when called from LabVIEW, but is working when called outside of LabVIEW. It appears that the Python code is being called twice. The log file is below, and I've attached an image of the LabVIEW code. There's nothing to it. Just call the script and end the session. If you look at the debug file, you can see that the Python code is executed twice. The first time everything is fine. The second time it fails. The failure on the second execution may make sense as the camera doesn't have time to clear and reinitialize between calls. Any ideas? Does LabVIEW launch the Python routine in some sort of behind the scenes loop? Do I need to clear some sort of buffer that has been flooded with calls to run the script?
just started
system paths D:\Users\jg\Temp
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface\.\
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\python37.zip
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\Lib
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\DLLs
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\lib\site-packages
just got system
just got camera list
just got number of cameras 1
about to begin acquisition
about to get image
just got image
getting image data
just got image data, rows 200 cols 2000
just about to save the image data
just saved the image data
just copied image data
about to release image
just started ??????? Why a second time?
system paths D:\Users\jg\Temp
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface\.\
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\python37.zip
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\Lib
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\DLLs
system paths C:\Program Files\National Instruments\Shared\NIPythonInterface
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37
system paths D:\Users\jg\AppData\Local\Programs\Python\Python37\lib\site-packages
just got system
just got camera list
just got number of cameras 0
03-23-2020 10:12 AM
03-23-2020 10:29 AM
I'm guessing the code is in a loop with Local Variables? If so, welcome to Race Conditions.
/Y
03-23-2020 10:33 AM
Is that picture of the BD all of your code or part of a bigger program? Is that boolean a button? How is it configured? Does it trigger twice?
02-27-2024 09:00 AM
I have a very similar problem reaching my device over python by Labview. Any help would be appreciated.