10-22-2022 04:40 PM
I'm calling functions from a Python script using a Python node in a malleable VI (attached). I verified that the Python script works as expected outside of LabView. However, when running it from within LabView, I sometimes get an error code 1672 with the message "There was an unknown Python error in the operation."
I found almost no information about this error online or within LabView, and I am unable to consistently replicate it. I tried calling it from another VI (within a loop) and letting it run for several hours; sometimes it gives the error after an hour, and sometimes it takes 7 hours to get the error.
I can't attach the Python script (proprietary), but it works fine outside of LabView. The behavior of the Python function that produces the error is a series of VISA Write operations.
I'm using 32-bit LabView version 18.0.1f4, on Windows 10. The Python interpreter is version 3.6.8.
Any advice would be appreciated!
10-22-2022 06:59 PM - edited 10-22-2022 07:00 PM
Perhaps it is trying to access an instrument at the same time LabVIEW is trying to?
10-23-2022 09:42 AM
Thanks for the reply! Is there a way to check programmatically if the connection is busy?
LabView doesn't interact with the instrument apart from calling the Python script, but I'm wondering if it's possible to delay the function call depending on whether the connection is in use.
10-23-2022 01:44 PM
I'm no expert at calling Python from LabVIEW, but I'm going to say, "probably not". Hopefully, someone with more expertise than I can answer definitively.
02-02-2023 10:50 PM
Any solutions/ known reasoning behind this issue yet?
02-23-2023 12:34 PM
I'm also interested in some additional details from NI on this issue. I have two projects, each capable of running successfully in the development environment (LV 32-bit, Python 3.9.6). Once each is built to an executable, the Executable generates this same 1672 error, in each case.
One of them has been tested on another environment and works fine in both development and executable, so I suspect it has to do with how the Python environment has been set up, but I'm unable to find any variables that matter.
02-23-2023 01:35 PM
I would suggest either contacting NI support or creating a new thread for your particular issue as the reason why you are receiving error 1672 is probably quite specific to your situation.
04-07-2023 04:53 AM
Hi !
I can consistently replicate this error using Python 3.9.13, numpy 1.24.2 and LabVIEW 2021 (all 32bit on Windows10 64bit 21H2) .
I am able to run correctly all python provided examples (Labview Help, Find examples) except the NumpyMatmul.vi
Any ideas ?
Dimitri
04-07-2023 11:13 AM
As a follow-up, we were finally able to trace this down on our end. The unknown error was eventually traced to incompatibilities within the Python environment. Unfortunately, there is very little documentation about this, but there are multiple libraries in the Python realm, such as scikit-image, numba, scipy and others, which themselves may call upon or have dependencies with libraries such as numpy. Here is the response I sent to NI Tech Support, since we had already opened up a support request ticket. By the way, these issues are relatively "new terrain" for NI, too:
"We resolved the 1672 error by setting up an environment within Anaconda, where we made sure we did NOT have overlapping incompatibilities in module dependencies between the following Python add-on modules: numpy, numba, scikit-image, and scipy. One interesting observation was that these incompatibilities were found to exist ONLY in context of a Python script being called by LabVIEW. Within the Python interpreter environment (Spyder 5.2.2), the discovered dependencies were COMPATIBLE (the Python script ran and returned results without error). It was only when calling the same Python script from a Python module in LabVIEW (Python 3.9.13, LabVIEW 2021 SP1, both of them 64-bit) that the error code 1672 occurred! The solution involves, by trial and error, reverting some of the Python add-on libraries (modules) mentioned above to earlier versions. Note that doing this ALSO tends to revert some of the additional dependent libraries, installed with these modules, to similarly earlier versions, so it is difficult to discern the exact “culprit” in the Python environment."
Understandably, since none of the authors of the individual third-party add-on libraries can anticipate which of their libraries might be used in conjunction with any other libraries, they are not too concerned about compatibility issues. And especially, as my comments to NI above demonstrate, whether or not these issues only surface in the context of a LabVIEW (and possibly other host languages) call to the Python script. For now, it pretty much falls upon the LabVIEW developer to figure out incompatibility issues.
Below, I've added some other links which may or may not be relevant to your situation, but I have found useful with regard to Python node work in LabVIEW:
Solved: Re: Python Node not working on EXE file (works on development computer) - NI Community
Advanced Datatypes with Python Node in LabVIEW (sasworkshops.com)
Passing Python Data Structures To/From LabVIEW with the Python Node - NI
Solved: Re: Error 1671 Python Node - NI Community
Solved: Re: Python Node not working on EXE file (works on development computer) - NI Community
LabVIEW 2023 Q1 Bug Fixes - NI (there is a direct reference to the 1672 error and use of Numpy)
04-10-2023 03:03 AM
Hello mkh_1064,
Kudos for this thorough and informative reply 👏👏