Using a NI DAQ Device with Python and NI DAQmx

Updated Sep 16, 2022



  • NI-DAQmx

Programming Language

  • Python

This article outlines the getting started steps to configure your PC to use the nidaqmx Python API.

Install Python and the NI-DAQmx Python API:
  1. Download and install Python
  2. Running the NI-DAQmx Python API requires NI-DAQmx or NI-DAQmx Runtime. Visit the to download NI-DAQmx.
  3. Install the NI-DAQmx Python API:
    • It can be installed with pip:
      • $ python -m pip install nidaqmx
    • Or easy_install from setuptools:
      • $ python -m easy_install nidaqmx
    • You also can download the project source and run:
      • $ python install
The NI-DAQmx Python Documentation explains how to install the Python support. The documentation for the nidaqmx Python package is hosted on the NI GitHub repository. It includes all of the nidaqmx Python example programs and the function definitions.

Test Python environment with nidaqmx:
  1. Open IDLE(Python).
  2. Type import nidaqmx and press enter.
  3. Type with nidaqmx.Task() as task: and press enter.
  4. Make sure to keep the Python indentation (four spaces) and type task.ai_channels.add_ai_voltage_chan("Dev1/ai0") press enter. Note that Dev1 is the name of the device connected to the computer. You can find this name in NI-MAX. You'll get an error if this name doesn't match. ai0 is the channel number that you want to use to acquire data. Make sure that this is the correct channel name.
  5. Type press enter
  6. You should be able to see the value read from the AI0 input of the Dev1 device.


The screenshot below illustrates the output of the steps mentioned in the Steps section.

The script below is the test script used in the Steps section of this article.

import nidaqmx
with nidaqmx.Task() as task:

Next Steps

  • Explore the nidaqmx Python API examples from our GitHub repository.