« Close

Datasheets and User Guides

App Notes

Software & Driver

 

Python for LJM - Windows, Mac, Linux

LJM Python Wrapper/Examples Windows/Mac/Linux (Software Platform)

Cross-platform Python wrapper and examples for the LJM library.

Release
12/04/2017

LJM Python Wrapper/Examples (Referencable)

Prerequisites

Instructions

  • Download/extract the .zip file attached at the top of this page.
  • Open a terminal/console window.
  • Using the command line, navigate to the extracted Python_LJM root directory.
  • Install the LJM Python modules by running the following command (remove the "sudo" on Windows):
    sudo python setup.py install

Refer to the download's README.TXT file for requirements, installation, documentation and license information.

Windows Troubleshooting

If running the "python setup.py install" command as described in the above instructions causes the following or similar error:

'python' is not recognized as an internal or external command, operable program or batch file.
That means either Python is not installed on your computer or the Python executable's path was not added to the Windows user or system path. To help resolve this issue, please run the Python Windows installer and in the "Customize Python" window, click the "Add python.exe to Path" option towards the bottom and select "Will be installed on local hard drive".



Then continue the installation as normal. Open a new terminal/console window and then go through our installation instructions again.

Alternatively, after Python is installed you can run the Python executable from its path. For example:

C:\Python27\python.exe setup.py install
Note that the above command uses the Python 2.7 path, and you should use the correct path on your computer which may differ.

Another option is to manually add the Python executable's path to the Windows path as described in the Python documentation.

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.
name = "SERIAL_NUMBER"
result = ljm.eReadName(handle, name)

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

5 comments

Is this package available for a pip install, I have the enthout canopy python distribution and it seems the only way to install external packages is via pip.

It looks like you can install the package on this page using pip since it contains a setup.py file for installation:

http://guide.python-distribute.org/pip.html#installing-from-other-sources

Try downloading the zip file and running (replace path/to to the directory the file is):

pip install path/to/Python_LJM_2013_12_30.zip

Alternatively, over the network you can try:

pip install http://labjack.com/sites/default/files/2013/12/Python_LJM_2013_12_30.zip

Note that the download's URL and zip file name uses dates, so future releases will have different URL paths and names. Before running either of the above commands, use the current "File attachment" download's URL or zip file name in your "pip install" command.

Can I get a simple Python example to start with LabJack T7 Pro ?

Are there Python code examples for the U3?

You'll want to take a look at the LabJackPython download (it has examples) and the quickstarts:

http://labjack.com/support/labjackpython

The LJM driver/wrapper currently only supports the LabJack T7 and Digit. Older LabJacks such as the U12, UE9, U3 and U6 are supported in LabJackPython.