Developer Center Resources

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Python Code from LabVIEW

This VI sends inputs to a simple Python script, and returns its output.  The basic method could be used to call code from many different languages, like Python, Perl, and Tcl.

Requirements: LabVIEW, Python

Instructions

  1. Download the simple Python script AddNumbers.py attached below.
  2. Download Calling Python Script.vi (or the PNG code snippet).
  3. Place the Python script and the VI in the same folder (this is simply expected by the example, and could be changed).

VI Details

  1. Build path to Python script, which is expected to be in the same folder as this VI.  Again, the Python script could be moved, but the code would have to reflect that change.
  2. Create the command line argument, in the form of pythonpath scriptpath int32 int32.  Quotation marks are used for the path, in case there are spaces.
  3. Execute the  argument.  The run in minimized, so that the command window does not quickly appear and disappear.
  4. Convert the string output from Python to an int.

Chris Bolin
LabVIEW Partner Program, CLA
Download All
Contributors