Skip to Navigation

LabJackPython (Windows UD, Mac, Linux)

LabJackPython is our cross-platform Python module for communicating with the LabJack U3/U6/UE9/U12. It works on Windows with the UD Driver and U12 Driver, and on Linux and Mac OS X with the Exodriver. For the LJM library (T7), use Python_LJM.


The latest stable release of LabJackPython is from April 24, 2014: Download 4-24-2014 release of LabJackPython.

For the latest development version, archived versions and code repository, visit LabJackPython on GitHub.


Python 2.5, 2.6, or 2.7. Python 3 is currently not supported. On Mac OS X, the built-in Python works, and it is 32- and 64-bit compatible. It also comes with Twisted, which you would need to use LJSocket. Use the built-in Python unless you have a good reason not to. Recent Linux distributions also ship with new enough versions of Python built in.

On Windows, the UD Driver for a UD device or the U12 Driver for a U12. On Linux and Mac OS X, the Exodriver.

If using Modbus, make sure your LabJack meets the minimum firmware requirement mentioned in the Modbus Support table on the UD Modbus page.


Unzip the file and open a terminal/command prompt. In the terminal, use the command line to go to the unzipped LabJackPython directory (e.g., “cd Desktop/LabJackPython” ). Then run one of the following commands to install the LabJackPython modules:


python install

Linux and Mac OS X

$ sudo python install

Note the LabJackPython zip file and unzipped directory name will vary on the download.


For LabJackPython documentation, please refer to the docstrings in the source code or use the help function. For example, documentation on classes and functions in the u3 module can be found in the source or by using the “help(u3)” call in Python (note to “import u3” first). For specific documentation on only the U3 class use “help(u3.U3)”.


LabJackPython provides both a Modbus and low-level command interface for performing operations on a LabJack device. Quickstarts can be found for both in the Modbus Quickstart and Low-level Commands Quickstart sections.

File attachment: 




Just got a U6 and have installed LabJack-02-02-2015.exe

I'm working on an up-to-date HP PC running Windows 7.

LJControlPanel works fine:

* Finds the USB U6, Test with jumper from DAC0 - AIN0 responds to changes on DAC0

LJLogUD works:

* I can log a signal from a function generator on AIN0

Kipling (3.0.6, LJM 1.0707, LJM Wrapper 0.0.13) fails to find any
devices. After clicking Refresh Devices, I get "Sorry, no devices

I've uninstalled everything, rebooted, and still no joy. Device Manager shows the U6 "working properly".

Python control is my ultimate goal, I have installed the files, and successfully installed the python
LJM library to my python (Anaconda 2.1.0) distro. Python can import the
LJM library. However my copy of your test code snippet: .................................

from labjack import ljm

# Open first found LabJack
handle = ljm.openS("ANY", "ANY", "ANY")

# Call eReadName to read the serial number from the LabJack.
result = ljm.eReadName(handle, name)

print("\neReadName result: ")
print("    %s = %f" % (name, result))


produces the following error in iPython:

In [1]: %run testcomm
LJMError                                  Traceback (most recent call last)
C:\Users\jhetrick\Documents\Python Scripts\ in <module>()
      3 # Open first found LabJack
----> 4 handle = ljm.openS("ANY", "ANY", "ANY")
      6 # Call eReadName to read the serial number from the LabJack.

\ljm.pyc in openS(deviceType, connectionType, identifier)
    301     error = _staticLib.LJM_OpenS(deviceType.encode("ascii"), connectionT
ype.encode("ascii"), identifier.encode("ascii"), ctypes.byref(cHandle))
    302     if error != errorcodes.NOERROR:
--> 303        raise LJMError(error)
    305     return cHandle.value

LJMError: LJM library error code 1298 LJME_ATTR_LOAD_COMM_FAILURE


Any advice welcome!  Thanks.




Kipling is for the LJM library, and the LJM library is just for the T7 at this time.  LJControlPanel is for UD devices (U3/U6/UE9) on Windows, and should work with your U6 as you confirmed.  For Python you don't want Python_LJM, but rather want LabJackPython from this page, so follow the steps above on down to "Quickstart".


In Python on Cygwin, I am able to call "import u6", but when I call "d = u6.U6()", I am getting a seg fault.  I ran a gdb backtrace, and it looked like there was an issue in the udlabjack dll file.  I'd appreciate any help on this.  We're excited to use this product.


On my Windows 7 machine, LabJackPython is working with Cygwin v1.7.32 without seg. faults. Try the following and see it helps:

1. Install the latest Windows driver software (currently "LabJack-2015-02-02.exe"):

2. Install the latest LabJackPython from github:

If that doesn't help, what versions of Windows, Cygwin and Python are you running, and are they the 32 or 64-bit versions?


I'm on Cygwin 1.7.34, 64 bit. I've tried on Windows 7 and Windows 8.1 64 bit. I'm using the latest version of the driver and I cloned the git repository last night.


If you install Python and LabJackPython on your Windows host (outside Cygwin) and run code using the Windows command prompt, does the seg. fault still occur?


Not on the windows 8 machine. We've been using it to collect data. I wanted to switch to Cygwin so I can use some Linux processing scripts and gnuplot for plotting data.

I will check on the windows 7 machine tomorrow.


I installed 32 bit cygwin on my 64 bit windows 8 machine and didn't get a seg fault.  I believe the issue is related to 64 bit cygwin.


I installed a 64-bit version of Cygwin and see the seg. fault now. We'll investigate the issue further and reply back to these comments when we have an update. In the meantime, it looks like to work around the issue use a 32-bit version of Cygwin.


I updated LabJackPython on github. Potentially the seg. faults could happen in 64-bit Python when using the UD driver (Windows only) in general, but this update/commit will resolve the issue. Let me know if you still encounter the issue after updating your LabJackPython in 64-bit Cygwin.


When I try to install for python, I'm told:

byte-compiling C:\Python34\Lib\site-packages\ to u12.cpython-34.pyc

  File "C:\Python34\Lib\site-packages\", line 369

    except OSError, e:


Does this only work in Python 2?



LabJackPython currently only supports Python 2.5, 2.6 and 2.7 as mentioned in the Requirements section on this page.

Regarding Python 3, refer to this comment on this page:



I am attempting to integrate a LJ U3 and LJ Tick-InAmp together to log the data from a thermocouple using a Python program. The U3 is also responsible for driving a relay that controls an actuator. as the relay and actuator are concerned, I have this functionality working, but am attempting to modify the extensive Python program I have in order to add the thermocouple functionality.

The relay is in FIO0 and FIO1, the LJTIA is connected to FIO2 and FIO3

First, I am curious if there is a way to call the function "TCVoltsToTemp.." in Python. I know this function can be used in LJLogUD so I hope it is accessible. 

Next, the data from the thermocouple must be extracted, so...

LJu3 = u3.U3()

v1 = LJu3.getfeedback(u3.AIN2()) #gets voltage from LJTIA OUTA

Temp = u3.TCVoltsToTemp[J:(v1 - 1.24)/201: 22) #converts v1 reading retrieved from AIN2 to Temp, Voffset = ~1.24 and G = 201x

Not sure if that's 100% so if someone could let me know if there's anything wrong there...

The TIA GND is connected via 10k resistor to InA+



On Windows, yes the UD driver functions are available in the LabJackPython module. For example (based on your TCVoltsToTemp call):

import LabJackPython

#Misc. code such as opening the device

#Get thermocouple voltage (in V) and cold junction temperature (in K)
temp = LabJackPython.TCVoltsToTemp(LabJackPython.LJ_ttJ, (v1-1.24)/201.0, 22)


UD driver documentation for TCVoltsToTemp is here (note pTCTempK is returned in Python and is not a parameter):

A helpful thermocouple app note can be found here:


Are there any Python 3.x support plans for the U3?  If so, what is the time-frame for doing this?


Currently there are no plans for Python 3 support for LabJackPython. There are however LabJackPython forks on github for Python 3 (the LabJackPython github link is on this page), and you can try the 2to3 converter script (

We do have Python 3 support for our Python interface to the new LJM library, but that is separate from LabJackPython and only supports the LabJack T7 at the moment.


Error in commented-out code in example:


In the example in LabJackPython-10-22-2012, there are commented-out chunks of

code that are supposed to work for U3 and U6.  One of them says

#d.configIO( NumberTimersEnabled = 1 )


I think that should be #d.configIO( NumberOfTimersEnabled = 1 ).



"d.configIO( NumberTimersEnabled = 1 )" is the correct call for the U6, and "d.configIO( NumberOfTimersEnabled = 1 )" should be the call for the U3. Looks like the low-level commands portion of the example were mainly for the U6. I updated the example on github with specific U3 and U6 low-level commands.


What is the clean way to remove power from the labjacks, then apply power again and keep the python code running? Here is some psuedocode for example:

>>>import u6
>>>u6_1 = u6.U6(serial = 360008508)
>>>u6_2 = u6.U6(serial = 360009180)
>>>v1 = u6_1.getFeedback(u6.AIN24(PositiveChannel=12, ResolutionIndex=8, GainIndex = 0, Differential = False))    #get a voltage reading
>>>v2 = u6_2.getFeedback(u6.AIN24(PositiveChannel=12, ResolutionIndex=8, GainIndex = 0, Differential = False))
>>>GPIO.output("P9_12", GPIO.LOW)    #power to the hub cuts out here
>>>time.sleep(20)    #sleep for 20 secs
>>>GPIO.output("P9_12", GPIO.HIGH)    #power restored to hub, labjack led's light up
>>>time.sleep(5)    #buffer time to wait for hub and labjacks to be restored
>>>v1 = u6_1.getFeedback(...)    #get some more voltage readings
>>>v2 = u6_2.getFeedback(...)

I've tried u6_1.close() and on each side of the sleep time, respectively, but I always get and error that says,

"LabJackPython.LabJackException: Could only write 0 of 12 bytes.

What am I doing wrong?

I appreciate your help.

Thank you.


If your U6 disconnects or loses power the current USB device handle becomes invalid. You should both close the U6 after losing power and then open your U6 again when it is enumerated. This cleans up the old, invalid handle in libusb and gets a new, valid handle. So after your "time.sleep(5)" when the U6s are enumerated (LED is on) and before your Feedback calls try:

u6_1 = u6.U6(serial = 360008508)
u6_2 = u6.U6(serial = 360009180)

If your U6 cannot be connected to, your u6.U6(...) call will return an exception.


That works perfectly. You guys are the best. Thanks.


I'm trying to use Epydoc to generate html documentation for LabJackPython.

While this works in general, the output has some 'features' which I can't explain. They may be due to Epydoc bugs, but I thought I would ask here.

For example, the documentation for the u3.U3 class lists 39 methods. For some reason, they all have a link to a "Method Details" section except for 2: binaryToCalibratedAnalogTemperature & loadConfig.

What makes these 2 methods different from the others?


Codewise both are public methods like the others. binaryToCalibratedAnalogTemperature doesn't have documentation or an assigned section (would be section 3), but loadConfig does have documentation and a section.

Using the built in Python help both methods show up with the documentation (if available). My guess for binaryToCalibratedAnalogTemperature not showing up in Epydoc details is that it is not documented. I don't know why loadConfig is missing though.


I noticed that contains the following comment:

Section Number Mapping:

1 = Object Functions

2 = User's Guide Functions

3 = Convenience Functions

4 = Private Helper Functions

A corresponding "section" variable is assigned after each U3 method.

What are these for?



Beyond organization reasons, I am not sure what the original intention of the "section" method attribute was as no other LabJackPython class does this or uses this attribute that I could find.


How do I stop the LabJack (U6 in my case) from outputting a voltage once I call d.writeRegister(DAC0_REGISTER, 1.5)? Is it as simple as setting it to d.writeRegister(DAC0_REGISTER, 0.)?


Yes, setting the DAC voltage to 0 will set the output to its lowest voltage of about 0 V. Note that the nominal minimum of a U6 DAC is 0.04 V.



I've started using LabJack U3-HV with LabJackPython. So I began reading here about LabJackPython and tried to use Low-Level Commands.

There is one thing that directed my attention: If I'am using d.getAIN(3), it results differ from the ones yielding by d.binaryToCalibratedAnalogVoltage(d.getFeedback(u3.AIN(3)) [0], isLowVoltage=False). (Besides fluctiuation from noise.)

This holds true after reaping calibration data. Using them uncalibrated they yield the same values.



  1. Putting a random chosen voltage on input 3.
  2. On python shell I'm typing:

>>> import u3
>>> d = u3.U3()
>>> for i in range (10): print d.binaryToCalibratedAnalogVoltage(d.getFeedback(u3.AIN(3)) [0], isLowVoltage=False), d.getAIN(3)
2.440864 2.440864
2.440864 2.440864
2.440864 2.440864
2.440864 2.440864
2.440864 2.440864
2.440864 2.440864
2.43584 2.43584
2.440864 2.440864
2.440864 2.43584
2.440864 2.43584

(There are some LSB-fluctuation due to noise.)

Let's continue:

>>> d.getCalibrationData()

(gives some output)

>>> for i in range (10): print d.binaryToCalibratedAnalogVoltage(d.getFeedback(u3.AIN(3)) [0],
isLowVoltage=False), d.getAIN(3)
2.46680050949 2.46430067183
2.46680050949 2.46430067183
2.46680050949 2.46430067183
2.46680050949 2.46430067183
2.46171616996 2.46430067183
2.46171616996 2.4592151402
2.46680050949 2.46430067183
2.46171616996 2.46430067183
2.46680050949 2.46430067183
2.46680050949 2.4592151402

There are some LSB-fluctuation, too. It can be clearly seen that both columns benefit from calibration data, but not in the same way.


Thanks for any hints – Peter


In your d.binaryToCalibratedAnalogVoltage call, you will want to set the channelNumber parameter to 3. It defaults to 0, meaning currently you are using AIN0 calibration constants for AIN3. getAIN is returning the correctly calibrated reading.

I noticed the example on this page isn't demonstrating this, so I will update it.


Ok, that resolves it. The missing parameter led to my conclusion that there is only one set of calbration data for all channels. And because in my example the difference is roughly half an LSB-step (albeit not observed exactly) it led me to the conclusion that there must be something like a kind of undocumented rounding feature.

Thanks – Peter


Is there a way to set the mode of an analog in to the 0-3v range?  I didn't see that in the python API however, I may have missed it.


If using a UE9 or U6, the Feedback command provides a BipGain (UE9) or GainIndex (U6) option that sets the range when reading analog inputs, or using Modbus starting at address 1500 you can set the range. Section 2.7.2 of the UE9 User's Guide and section 2.6.2 of the U6 User's Guide documents gain and voltage ranges.

If using a U3, use the getAIN and set negChannel to 32 (special). This sets the range to 0-3.6 V or -10/+20 (HV). See section 2.6.2 of the U3 User's Guide for voltage ranges. Look at the U3.getAIN method's source code to see how the reading is done and section 2.6.1 describes what negative channel 32 does in the UD driver and the getAIN call.



I am trying to get the Python library work in Cygwin, running Python 2.7.3. Installation seems to work out fine, but when running one of the examples, the library tries to load the Exodriver, not the UD driver:

$ python2.7

<class 'LabJackPython.LabJackException'>: Could not load the Exodriver driver. Ethernet connectivity only.

Etc. Is there some way to force the setup to use UD instead?



It looks like Cygwin's Linux-like environment makes a Python module we use report the OS as "posix" instead of "nt". You can force LabJackPython to use the UD driver by modifying its source code. The dll/library load code is in the _loadLibrary function in the file but the Python call to detect the OS,, is used throughout the file. You can try to fake the call by removing the the "import os" import in and adding a class and global object after the imports like this:

class OS(object):
    def __init__(self): = "nt"

os = OS()

I did a quick test and that got the example running in Cygwin.


Got it running with the example code you provided, with the addition that I needed to change ctypes.windll to ctypes.cdll everywhere in



Glad to hear you got it running. In my Cygwin tests ctypes.windll was working. I only needed code changes to force to equal "nt".


If you are running a 64-bit version of python and you get the following error:

<class 'LabJackPython.LabJackException'>: Could not load labjackud driver.

    The error was: [Error 126] The specified module could not be found

Please install the 64-bit driver install of the driver package located here:

For the developers, could you please correct the python library to reference 32-bit / 64-bit dlls properly? It appears if you have a 64-bit python and try to run the examples, python errors due to missing dlls because the driver installer only installs 32-bit dlls on a 64-bit windows system. 



This cannot be fixed in the Python library.  64-bit Python programs can only load 64-bit dlls and cannot load/reference 32-bit dlls.  So user's with 64-bit operating systems need 64-bit Python and the 64-bit UD driver, or 32-bit Python and the 32-bit UD driver.  We have however just updated our UD installer to install both 32 and 64-bit versions of the driver that should help with future cases of this.  This starts with UD installer version 3.32, which is currently (01/24/2013) is in beta:


I have the same issue of #16:

Traceback (most recent call last):

File "C:\Python25\", line 11, in <module>

d.writeRegister(DAC0_REGISTER, 1.5) # Set DAC0 to 1.5 V

File "C:\Python27\lib\site-packages\", line 434, in writeRegister

return self._parseWriteRegisterResponse(response, pkt, value)

File "C:\Python27\lib\site-packages\", line 490, in _parseWriteRegisterResponse

if request[7] != response[7]:

IndexError: list index out of range



When I read the content in #17:

"Modbus over both USB and ethernet support was not available until Comm firmware version 1.48. You are using version 1.40 which did not support Modbus yet, so that is the cause of the problem. Try installing the newest beta Comm firmware, and see if that help."

I am not sure what "Comm firmware" is and how to upgrade it?




Firmware is code on the LabJack device, and Comm firmware is specifically for the UE9's Comm processor.  Download the UE9comm_152_12152011.bin firmware file here:

Then use the LJSelfUpgrade program to upgrade your UE9's Comm firmware with the downloaded .bin file.  LJSelfUpgrade should already be installed on your computer since it is installed with the Windows UD driver's setup.  Take a look here for documentation on LJSelfUpgrade:


So, I've had luck getting the LabJack to control LEDs (on/off) when they are connected to ports FIO0 & FI01, using the following code I call "":


import u3, random

d = u3.U3()





for i in range(0, 100):


   d.writeRegister(FIO0_STATE_REGISTER, random.choice((0,1)))

    d.writeRegister(FIO1_STATE_REGISTER, random.choice((0,1)))



But now I want to use the 15-pin digital output port to send a signal (like a TTL pulse do a different device). I've tried using the same code, and changing the register numbers, but nothing seems to work. Any suggestions on how I should modify the code to send a signal out of the digital output port? If I install the software on the CD, I can generate a signal, so I know my hardware is working. It's just a question of finding the right Python syntax. 

Any help would be greatly appreciated, thanks in advance,

Josh Salmon


I tested the FIO, EIO and CIO digital lines using Modbus and they are working fine.  Writing to Modbus addresses 6000-6019 will set the digital output states, where addresses 6000-6007 correspond to FIO0-FIO7, 6008-6015 to EIO0-EIO7 and 6016-6019 to CIO0-CIO3.  So something like this in Python will set EIO1 (DB15 pin 12) to an output-high state:

d.writeRegister(EIO1_STATE_REGISTER, 1)

If you are still seeing problems, try updating your U3 to the latest firmware and see if that helps:


I think that the "try - except - finally" construct in Python is really useful for instrumentation applications. I am using it in my ue9 development activity, but I am not sure what exception codes to use in the "except:" clauses I write. There are standard Python exception classes, but I wonder - are there any LabJack specific exception codes available?  Thanks!



There is the LabJackException class that is thrown for LabJack specific exceptions.  It contains an errorCode and errorString.  The errorCode is a UD driver error code (Windows only), the errno set by the Exodriver (Linux/Mac OS X only), -1 for Python wrapper errors, or 0 for a nonspecific (default) error code number.  The errorString describes the error.  The LabJackException class can be found in the source code.




Python 2.7.3 (default, Apr 20 2012, 22:44:07) 

[GCC 4.6.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import ue9

>>> d=ue9.UE9()

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/local/lib/python2.7/dist-packages/", line 68, in __init__**kargs)

  File "/usr/local/lib/python2.7/dist-packages/", line 87, in open, 9, Ethernet = ethernet, firstFound = firstFound, serial = serial, localId = localId, devNumber = devNumber, ipAddress = ipAddress, handleOnly = handleOnly, LJSocket = LJSocket)

  File "/usr/local/lib/python2.7/dist-packages/", line 600, in open

    d = openLabJack(devType, ct, firstFound = True, handleOnly = handleOnly, LJSocket = LJSocket)

  File "/usr/local/lib/python2.7/dist-packages/", line 1454, in openLabJack

    return _makeDeviceFromHandle(handle, deviceType)

  File "/usr/local/lib/python2.7/dist-packages/", line 1498, in _makeDeviceFromHandle

    raise e  

LabJackPython.LabJackException: Could only write 0 of 38 bytes.

Do you know what seems to be the problem? Normally I never get this kind of problem..this thing never occurred before..please help. 



Looks like a command is not getting through when opening your device.  You can try your "d=ue9.UE9()" call a couple of more times and see if that helps to clear the issue, otherwise power cycling your UE9 usually fixes most problems.  Let us know if this does not help.

I would need more information to figure out what caused the problem.  If this occurs again, let us know of any other calls you have made previous to this error.  If you ran a previous program/Python interactive mode session please provide the calls you made there.  Also, provide your UE9's Control and Comm firmware versions.


From the text above:

"First, before we perform any other operation we will get your LabJack device’s calibration data. [getCalibrationData()] only needs to be performed once after opening your device. The calibration data will be used by functions that convert binary data to voltage/temperature and vice versa."

Since calling getCalibrationData() should be done every time you first open a LabJack device before doing readings that convert binary data to temp/voltage values and because it also takes no arguments, why is it not part of the constructor?  Is there any reason you would not call this function?  I can understand that, if you were only doing digital IO, you would not need it however, having a separate call for this seems to imply that it is important to not call this function in some circumstances.  Is this true? i.e. Does calling this function change the behavior of the LabJack device if only doing digital IO?  Does it hurt to call this function every time a LabJack device is used?  If not, why have a separate call?


Using getCalibrationData is only necessary when using low-level commands and temperature/voltages.  Using Modbus (the first set of "Basic I/O" examples) you do not need to read the calibration.  It doesn't hurt to call this automatically, but considering it is only used for low-level commands we let the user perform the getCalibrationData call based on if they need it or not.


Hello, I got that error message after a while:


in _checkCommandBytes

    raise LabJackException("Got incorrect command bytes.\nExpected: %s\nGot: %s\nFull packet: %s" % (hexWithoutQuotes(commandBytes), hexWithoutQuotes(results[1:(size+1)]), hexWithoutQuotes(results)))

LabJackException: Got incorrect command bytes.

Expected: [0xf8, 0x5, 0x39]

Got: [0xf8, 0x2, 0x0]

Full packet: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0x97, 0xb7, 0x4, 0x23] 

Is this my fault?thanks



What LabJack device and operating system are you using?  Also, can you provide the chunk of your code that leads to this exception?