Integrating Python Code in NI DIAdem

Overview

This page outlines the steps to install additional Python modules in NI DIAdem, both interactively or programmatically. The Python functionality was introduced in NI DIAdem in 2020 and is not available in previous versions. It requires NI DIAdem, Python, and the PyWin32 module to be installed. 

 

NI DIAdem interacts with Python by looking up the Python version that is entered in the DIAdem configuration for SCRIPT. If this is empty (the default), DIAdem takes the Python version that is entered in the Windows path environment. In all other cases and if DIAdem finds an installed version that is not 3.7 or 3.6, DIAdem takes the version that is installed together with DIAdem. 

Contents

NI DIAdem and Python Compatibility

The following table determines which version of Python is compatible with which NI DIAdem version.

For DIAdem versions up to 2022 Q4, DIAdem installs Python. As of DIAdem 2023 Q2, DIAdem no longer installs Python. If you want to use Python scripts in DIAdem, install a Python version supported by DIAdem, which can be found at https://www.python.org/ if you don't have it installed. 

DIAdem VersionPython Version
3.123.113.103.93.83.73.6
2024 Q4
2024 Q2
2023 Q4 
2023 Q2  
2022 Q4  
2022 Q2   
2021 SP1   
2021   
2020 SP1     
2020     

Compatible

 

Installing Additional Python Modules to NI DIAdem

The three methods for installing additional python modules to NI DIAdem are, Interactively, Programmatically and Manually

Interactively

This method interacts with the built in functionality of NI DIAdem.

  1. Open NI DIAdem.
  2. Navigate to Settings >> DIAdem Settings >> Script.
  3. Enter the Python module name in the corresponding text box.
  4. Click Install/ Update Module.

 

Programmatically

This method uses a script to achieve the same result by calling the Command Prompt and running the pip install command. 

For a Python script, you would use the command: 

subprocess.run(["pip", "install", "<ModuleName>"])

If it is necessary to display the module installation output in NI DIAdem, you can use the following example where the Panda module is being installed (besides the two lines of code, an import has been added at the top): 

Test = subprocess.run([“pip”, “install”, “numpy”],stdout=subprocess.PIPE, text=True) Print(test.stdout)

DIAdem SCRIPT Panel showing new script with code to install python module and printing the result. Includes the DIAdem pre-written code

Manually

This method uses the Command Prompt interactively, without opening NI DIAdem.

  1. Right-click the Start charm.
  2. Type cmd, right-click the Command Prompt tile and select Run as administrator.
  3. Navigate to the DIAdem installation of Python using cd C:\Program Files\NationalInstruments\Shared\Skyline\Python.
  4. Navigate into the Python <version> folder, then into the Scripts Folder.
  5. Perform any necessary install using pip install moduleName.