Examples

Each of these examples has two parts: a LabVIEW VI, and a corresponding Python file on disk. The Python files live right next to the LabVIEW files in the LabVIEW "examples" directory.

Download all the examples as a ZIP file.

Certain examples use Python to talk to web services, like Plot.ly or the Google/Bing Speech Recognition APIs. These are free to use but may ask that you sign up for an API key before use. Instructions for how to do this are on the front panels of these VI's.

Basic Use

Hello World

The classic introductory example. Launch a Python session, send it your name, and Python returns a greeting.

Getting and Setting Variables

Demonstrates how to get or set the value of a Python global variable.

Performing Basic Math

Simple example of how to perform mathematical operations with the Toolkit. Supply an array to Python, have it transformed, and returned back to LabVIEW.

Using Python Interactively

See how a persistent Python session can perform computations and other activities on demand, as opposed to being run as a script. This example uses a LabVIEW event loop to set Python variables and call Python functions on demand

Python for Signal and Image Processing

Finding Frequency Bursts

High-level languages like Python are ideal for solving thorny problems like event detection and signal classification. In this example, we use some of Python's tools for frequency analysis to find high-frequency noise bursts within a signal.

Automated Face Recognition with OpenCV

Many tools exist in the Python world for high-level problems like computer vision and machine learning. In this example, we show how to use the OpenCV Python package to recognize faces in an image series.

Web and Cloud Connectivity

Speech Recognition Powered by a Cloud Service

We show how acquire data with LabVIEW (in this case microphone audio) and submit it to a cloud service for analysis. This example records a brief snippet of sound using your computer's microphone, and then uses the Python speech_recognition package to connect to the Google or Bing speech recognition API.

Publishing Data on the Web using Plot.ly

Use Python to share data directly from LabVIEW to the web, by submitting it to the Plot.ly cloud service. Graphs generated with Plot.ly can be viewed, edited and shared online.

Streaming Data to a Python-Powered Dashboard

This example shows how to run a Python dashboard that can be accessed from a web browser. Incoming data from LabVIEW is continuously fed to Python and appears on the dashboard, along with summary information and statistics.

Advanced Python Features

Capture Printed Output

Shows how to redirect Python's standard output stream, to capture information printed to the console by Python code.

Concurrency with Python

Demonstrates how to launch a long-running Python program and interact with it from LabVIEW, using threads, queues, and global variables. A long-running Python function can return partial results or status updates to LabVIEW, and LabVIEW can control the function's execution or instruct it to exit early.