Error 1667 When Using Python Node in LabVIEW

Updated Feb 16, 2024

Reported In

Software

  • LabVIEW

Issue Details

When I use Python Node to call a Python function in LabVIEW, it shows that the module cannot be found and I get the following error message:

Error 1667 occurred at Python Node in Test.vi

Possible reason(s):
LabVIEW: (Hex 0x683) The specified Python module could not be imported.


In the screenshot below you can see an example of how this error might look:
 
image.png

Solution

This issue can happen for several reasons, normally the root cause is specified in the last part of the error where it says ImportError. This part of the error message can give a better idea of the source of the error.

If the import error says Attempted relative import with no known parent package then it could be that the Python Node is failing to interpret a relative import used in the module. Please try one of the following workarounds:
  • Convert the relative import to an absolute import. This can normally be achieved by removing the leading dots that relative imports use. The syntax of a relative import depends on the current location as well as the location of the module to be imported so you need to check how to change it to an absolute path for the specific module you are using. In the following external link, you can read more about relative imports: Absolute vs Relative Imports in Python.
  • This error can happen if you call a function directly from an installed Python package that uses relative imports. If the function you are trying to call from LabVIEW works properly when called from a Python script and ran from a different IDE, a workaround is to create a wrapper Python script to call the function indirectly and not directly from the installed module.

If the import error says No module named ... then it can be related to the Python path not being set correctly. Please try the following steps to fix this issue:
  1. Reinstall Python and make sure to select the "Add Python X.X to Path" option during installation.
  2. After the installation is complete, open the command prompt to install the module as required. An example command is as follows: "pip2 install opencv-python".