Python3 support?

8 posts / 0 new
Last post
joost
joost's picture
Python3 support?

On the GITHub readme it states: "Modules have been updated for Python 3.x but not all functionality has been tested yet".  However I get an error right at import u3:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 19, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/u3.py", line 684
    except LowlevelErrorException, e:

SyntaxError: invalid syntax

 

Seems to suggest that Python 3 is not supported at all?

LabJack Support
LabJack Support's picture
Our release versions are only

Our release versions are only Python 2 compatible For Python 3, please download and install the development version of LabJackPython from GitHub. Use the "Clone or Download" button:

https://github.com/labjack/LabJackPython

joost
joost's picture
And that is exactly what I

And that is exactly what I did, cloned it and building it went fine. However, the import gives me the error mentioned above.

LabJack Support
LabJack Support's picture
Based on this exception's

Based on this exception's line number and code:

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/u3.py", line 684
    except LowlevelErrorException, e:

This looks like code from around LabJackPython release 8-26-2011 or older. Current GitHub code doesn't have that call which is Python 3 incompatible. I'm not sure why, but it seems like your clone is getting old files, or your computer's Python installation has old module files.

Delete your cloned repository, and the following files from "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/":

LabJackPython-<DATE-PYVER>.egg
LabJackPython.py
Modbus.py
skymote.py
u3.py
u6.py
u12.py
ue9.py

Note that the LabJackPython-<DATE-PYVER>.egg filename will depend on the version installed, so erase the egg file that starts with LabJackPython. The current GitHub development version installs just the egg file with the modules packaged inside.

In case there is an issue with cloning, download the zip file of LabJackPython from GitHub in the link provided in my last post. Unzip the contents and install the modules. That should provide the Python 3 compatible version of LabJackPython.

joost
joost's picture
Alright, problem solved.  The

Alright, problem solved.  The PyCharm environment I am in seems a little goofed up as it does some automation installing/suggesting to install libraries through its own interface. It connects to pypi which is where labjack's old libs are. Between that, its odd handling of venv and labjack's somewhat unintuitive versioning (there is a 1.201505, 9-20-2010, 4-24-2014 and now 5-26-2015, the latter seems the same as the first) it did indeed pick an old version.

Removed all the libs and did the python3 setup.py install and all is well (though not using venv).

 

May I suggest (as have others before me) you officially switch to python (3) and dump legacy python (2) and support it on pypi?  Python (3) has been up for many years now, its popularity has certainly improved much and legacy python (2) is not going to be supported in a year and half.  Just to illustrate; I am actively removing/replacing _anything and all_ software which require 2.7 or below (except OS related stuff). All our code is written in python and legacy python code has been replaced.

Thanks for your support!

LabJack Support
LabJack Support's picture
We may drop the 9-20-2010 and

We may drop the 9-20-2010 and 4-24-2014 Python 2 releases at some point due to the way they were versioned, but will likely keep 1.201505 (5-26-2015) since it's version is PyPI compatible, and the official Python 3 release will be version 2. The Python 3 version isn't on PyPI since it is considered beta and not fully tested for Python 3 compatibility.

LabJackPython development is currently limited to bug and compatible fixes that users report since we are focusing on newer products. The LabJack T7 and T4, our last two DAQs released, have a different Python library that is fully Python 3 compatible.

LabJack Support
LabJack Support's picture
To update, our latest

To update, our latest LabJackPython release, v2.0.0, officially supports Python 3. It can be download from our site or its GitHub repository. It is also available on PyPI and can be installed using a package installer such as pip.

joost
joost's picture
Thanks for continuing Python

Thanks for continuing Python support for your product!