This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Install Python for NI TestStand

Updated Nov 22, 2024

Environment

Other

Software

  • TestStand

Programming Language

  • Python

    If you want to use Python Steps in NI TestStand, you first need to install Python. After downloading Python, you will do a custom installation to prepare Python to be found in NI TestStand.

    The following guide describes installing Python for NI TestStand 2024 Q4. This process can be followed for older (or newer) NI TestStand versions with slight adaptions.

    Python Steps were first available in NI TestStand 2019. For older versions of NI TestStand you will need to use the Call Executable Step instead. For this use case, see Calling Scripting Languages from NI TestStand.

    Download Python

    1. Use the table below to identify a supported version of Python for your version of NI TestStand.

    Supported Python Adapters:

    NI TestStand VersionPython Versions Supported
    2024 Q43.8, 3.9, 3.10, 3.11, 3.12
    2023 Q43.8, 3.9, 3.10, 3.11
    2022 Q43.7, 3.8, 3.9, 3.10
    2021 SP13.6, 3.7, 3.8, 3.9, 3.10



    2. Download the Windows installer for Python.

    Install Python

    1. Run the Python installer.

    2. Make sure you checked the Add python.exe to PATH checkbox. In order for TestStand to find the Python Interpreter, Python will need to be added to
    the PATH environment variable.

    3. Choose Customize Installation.

    01_Customized Installation.png

    4. In the Advanced Options settings:

    • Enable Install for all users.
    • Install in a location other than “C:\Program Files” or C:\Program Files (86)”, as shown below.

      02_Customized Installation.png


    Setting the Python Adapter in TestStand

    1. In the Teststand File Menu, go to Configure >> Adapters… >> Python >> Configure…

    2. Choose the Python version you installed.

    03_Python Version.png

    3. You might want to check Display console for interpreter sessions.

    Attention: If you do check Display console for interpreter sessions, during adapter calls a console window is opened, and print() commands will be shown. It is generally suggested not to check this checkbox for deployment, as then you would need to manually handle the console popups. Please also keep in mind not to close the console windows manually - the python adapter will crash if you do, and you will need to Unload all modules before you can use Python Adapters again.

    4. You might want to use a Virtual Environment using virtualenv. See KB Article TestStand's Python Adapter Configuration Shows Invalid Virtual Environment Path for more information.

    For more information on the Python Adapter Configuration see NI TestStand Help >> Python Adapter.


    Done.

    You are done installing Python for NI TestStand. You will find Python examples for TestStand steps in the Related Links section below.

    Next Steps