Is Python 3.x on the horizon? | LabJack
 

Is Python 3.x on the horizon?

8 posts / 0 new
Last post
Chris R
Christopher Rodgers's picture
Is Python 3.x on the horizon?

I know that Python 3.x is not officially supported for the UE9. It only works for 2.7.

But Python 3.6 is what I have to work with in our labs right now, and I'd really like to use the UE9 extensively for projects with Python

Is there any way to get the UE9 working with Python 3.x? Maybe I missed something, but I'm not seeing this on Github or anywhere else.

And if not, is Python 3.x even on the horizon for UE9 or any Labjack devices? Please let me know.

Thanks! Chris

Chris R
Christopher Rodgers's picture
Something strange seems to

Something strange seems to have happened...I saw a reply to this from the LabJack Team appear here on the Forum, then it disappeared. Here's what you e-mailed me:

"Other devices previous to them (U12, UE9, U3, U6) that use LabJackPython have beta Python 3.x support on GitHub. We have updated/tested much of its code for Python 3.x but have not fully tested all functionality (we mention this in the GitHub repo. README). Try the GitHub version and if you run into any bugs with some UE9 functionality you are using, let us know and we will look into fixing it.

https://github.com/labjack/LabJackPython"

Yes, thanks, I have looked through the material on Github, but I seem to be missing something. I'm having trouble getting started, as I'm new to Python, let alone the UE9.

I'm happy to take my chances with Beta and so forth. I won't need all the full blown features of the UE9, probably just some simple Digital IO, perhaps a couple of AIN's. I'm using Anaconda 3.6 (64 bit).

Can you please tell me what files I need to load/install to get talking to the UE9 from Python (using posted templates, which I can edit)?

And where can I find these files/libraries?

Any direction would be greatly appreciated.

Thanks! Chris

LabJack Support
labjack support's picture
LabJackPython (which supports

LabJackPython (which supports the U12, UE9, U3 and U6) has beta Python 3.x support on GitHub, so use that version with Python 3.6 and your UE9.

https://github.com/labjack/LabJackPython

As the GitHub README mentions, "Modules have been updated for Python 3.x but not all functionality has been tested yet". If some functionality you are trying to use has some issues, let us know and we can look into fixing it for you.

Fully testing/updating LabJackPython for Python 3.x for a stable release on our site is on our todo list, but has no timeline and is lower priority.

As for our newer T-Series devices, the T7 and soon to be released T4, they have official Python 3.x support and use LJM Python.

LabJack Support
labjack support's picture
Something strange seems to

Something strange seems to have happened...I saw a reply to this from the LabJack Team appear here on the Forum, then it disappeared.

There were some website technical difficulties earlier today. My original forum post was lost, and my most recent post was before I saw your last post.

First, make sure you have the latest version of our drivers installed for the correct operating system.

Windows: https://labjack.com/support/software/installers

Linux / Mac: https://labjack.com/support/software/installers/exodriver

Then install our Python modules from the files provided on GitHub which was linked to previously. On that page click "Clone or download" to download the files in a zip, and unzip those on your computer. Refer to the README file for the terminal command to run for installation of the modules and some quick UE9 commands to run to read device information.

I am not familiar with the Anaconda environment, but typically in Python using a terminal you run these commands:

cd <LJP_DIR>

sudo python setup.py install

Note that the cd command changes the directory, and you need to replace <LJP_DIR> to the unzipped LabJackPython directory on your computer. On Windows, leave off the sudo in the second command.

We don't have many UE9 example files, but refer to the ue9 module Python doc. for class and method usage. We mention how to get to this documentation here in the Documentation section (replace u3 with ue9):

https://labjack.com/support/software/examples/ud/labjackpython

In particular, the ue9.UE9.feedback method reads analog inputs and sets/reads digital I/O. I've attached a simple Python example (remove the .txt file extension) for the UE9. Its code demonstrates Feedback usage.

Last, if you are new to Python, I suggest reading some Python documentation and tutorials. Concepts like modules, classes and general syntax make understanding UE9 Python code easier.

File Attachment: 
Chris R
Christopher Rodgers's picture
Thanks very much for the

Thanks very much for the directions and the prompt turn around! These are exactly the type of simple things I wish to do. This is all giving me hope!

I installed the latest drivers and the Python modules from Github. I can import ue9

But when I try to run the whole ue9_demo.1.py example you provided, the program can't seem to find the UE9 (please find console output attached). The last line says "LabJack not found".

This maybe makes sense, since the UE9 is connected by LAN and there's nothing indicating the IP address in the code. (I have confirmed by LJ Control Panel 2.33 that it is indeed connected and working.)

The UE9 IP address is static, so I could specify it.

How can I set the UE9 IP address in the example code? Or even scan the network like LJ Control Panel 2.33 does?

Thanks! Chris

File Attachment: 
LabJack Support
labjack support's picture
The example connects to the

The example connects to the first found UE9 over USB. For Ethernet, ethernet and ipAddress need to be specified. Change the UE9 constructor call in the code to something like this for an Ethernet connection (change 192.168.1.205 to your IP address):

# Open UE9 over Ethernet with a specified IP address.
d = ue9.UE9(ethernet=True, ipAddress="192.168.1.205")

Note that this call does not scan the network. You can use the LabJackPython.listAll function though to scan the network and provide device details, similar to what LJControlPanel does (scan network and then open found devices):

import LabJackPython
print(LabJackPython.listAll(9, 2))  # Discover UE9 devices over Ethernet and display the results

Chris R
Christopher Rodgers's picture
That was it, everything

That was it, everything worked perfectly! Thanks so much for your help with this. Now I know what I'm doing and can finally put my 12+ UE9's to work.

Up here in Canada this is Thanksgiving weekend. You've given me a lot to be thankful for!

Have a good one!

LabJack Support
labjack support's picture
For Python users coming

For Python users coming across this topic and regarding Python 3.x support, the recently released LabJackPython for the LabJack U12, UE9, U3 and U6 has Python 3 support:

https://labjack.com/support/software/examples/ud/labjackpython

It can also be downloaded (modules only, no examples) through PyPi with a Python package manager such as pip.

For our newer DAQs, The LabJack T7 and T4, there is Python for LJM with Python 3 support:

https://labjack.com/support/software/examples/ljm/python