Python Adaptor in TestStand

Python Adaptor in TestStand

I wrote a recent post about calling Python from LabVIEW. As it turns out you can also call Python directly from Test Stand as well. In TestStand 2019 a new Python Adaptor was added. Rather than create my own example, I will just point you to the shipping example. It’s pretty good. What I’d rather talk about briefly is how to set up the adaptor and the differences between calling Python in TestStand and LabVIEW.

Here is the example in TestStand Help. Just search for Python.

Adaptor Settings

Python Adaptor Settings

So the first settings are the interpreter settings. You can use one global session or you can use a separate session per thread or execution. In the adaptor settings screen you must select a single Python Version. This dialog also lets you point TestStand to a Virtual Environment. In addition, you can decide whether you want to display the console or not. That can be useful for debugging. You can also select the module viewer and point it to an IDE like Pycharm or your favorite text editor.

Per step advanced settings.

The other thing worth noting is that on any Python step you can spawn a new interpreter session and store it in a Teststand variable and then use that on subsequent steps. To set the interpreter for a particular step, go to its module tab, and to the right of the dropdown where you select the python module, click on the advanced button. Note that this will let you call different versions of Python from TestStand at the same time.

Differences with LabVIEW

We have already discussed the biggest difference between calling Python in LabVIEW and Teststand and that is that TestStand supports Virtual Environments. This is pretty huge.

There is another difference and that is that TestStand supports Python Objects. So you can retrieve an object from a Python method and store it in a TestStand variable for future use. Of course you must use it inside the same Python Interpreter Session for it to be valid.

If you need help integrating Python with either LabVIEW or TestStand, please reach out. We’d love to talk to you.