LabJack LJM
raw JSON → 1.23.0 verified Mon Apr 27 auth: no python
Python wrapper for the LabJack LJM library, used to control LabJack T4, T7, and T8 devices. Version 1.23.0 released in 2024. Active development with periodic updates.
pip install labjack-ljm Common errors
error LJMError: LJM_ERROR_DEVICE_NOT_FOUND ↓
cause Device not connected or LJM library not installed properly.
fix
Check USB/ethernet connection, ensure device is powered, and verify LJM native library is installed (run 'ljm_install' or see LabJack docs).
error ImportError: No module named labjack.ljm ↓
cause labjack-ljm Python package not installed or wrong import path.
fix
Install with 'pip install labjack-ljm' and import using 'import labjack.ljm as ljm'.
error LJMError: LJM_ERROR_INVALID_HANDLE ↓
cause Device handle is invalid (closed or never opened).
fix
Ensure handle is obtained from ljm.openS() and not closed before use.
error LJMError: LJM_ERROR_LIBRARY_NOT_FOUND ↓
cause Native LJM library (liblabjacklm.so or LabJackLM.dll) not found in system library path.
fix
Install the LJM native library from LabJack's website. On Linux, set LD_LIBRARY_PATH to the directory containing the library.
Warnings
breaking LabJack T8 support introduced in LJM 1.20.0. Older LJM versions do not support T8 devices. Update accordingly. ↓
fix Upgrade to labjack-ljm >= 1.20.0 to use T8.
breaking In LJM 1.22.0, some function signatures changed (e.g., eWriteName now expects a float for analog outputs instead of int). ↓
fix Check the release notes for exact changes. Use floats for analog values.
gotcha LJM requires the LabJack LJM library (shared library) to be installed on the system. pip install does not install the native library. ↓
fix Download and install LJM from LabJack's website (https://labjack.com/support/software/ljm).
gotcha When opening devices, ensure only one instance of the device is open. Multiple handles to the same device can cause undefined behavior. ↓
fix Always close the handle after use with ljm.close(handle).
deprecated ljm.listAll() is deprecated; use ljm.listAllS() instead. ↓
fix Replace ljm.listAll() with ljm.listAllS() in your code.
Imports
- LJM wrong
from labjack import ljmcorrectimport labjack.ljm as ljm - LJM
from labjack import ljm
Quickstart
import labjack.ljm as ljm
# Open first found LabJack device
handle = ljm.openS("ANY", "ANY", "ANY") # returns handle
info = ljm.getHandleInfo(handle)
print(f"Opened a LabJack with device type: {info[0]} connection type: {info[1]} serial number: {info[2]} IP address: {info[3]} port: {info[4]} max bytes per MB: {info[5]}")
# Write and read analog output
ljm.eWriteName(handle, "DAC0", 2.5) # set DAC0 to 2.5V
value = ljm.eReadName(handle, "DAC0")
print(f"DAC0 value: {value}")
ljm.close(handle)