BGE implementation of LabJack Python Library | LabJack
 

BGE implementation of LabJack Python Library

7 posts / 0 new
Last post
CorX7
CorX7's picture
BGE implementation of LabJack Python Library
LabJack Support
labjack support's picture
By BGE, do you mean Blender

By BGE, do you mean Blender Game Engine? If so, then no we do not provide a BGE specific implementation.

I'm not familiar with the BGE environment, but in its Python distribution can you install Python modules? If so then try installing with the setup.py file and BGE's Python as described in the installation instructions. Alternatively, you can try adding our module .py files in the same directory as your code files.

Note that LabJackPython for the U12, UE9, U3 and U6 currently only supports Python 2.5 to 2.7. Our LJM Python wrapper/library for the LabJack T7 supports Python 2.5 to 2.7, and 3.x.

CorX7
CorX7's picture
I looked through setup.py. I

I looked through setup.py. I found that it only references these files.

import sys
from distutils.core import setup

In blender the distutils is identical but its own file. Blender just duplicates the Python2.7 into its main folder. Even though I copied all the files from Python2.7 site-packages into Blender /lib/ site-packages, the blender engine now correctly locates that u3.py is  there and imports it but has that error on line 28 when it tries to locate LabJackPython.py. I think the installation script adds the desktop LabJackPython-5-26-2015/src folder to the working modules of Python2.7?

I know this should be easy but I am not familiar with the installation scripts and path finding for modules.

CorX7
CorX7's picture
You were right the version of

You were right the version of blender that I am using is Blender2.76 (the external python libraries are Python2.7) the bundled version is Python3.4. I will load my work into Blender 2.5 which is compatible with Python2.7 (I still use it for many other applications). Thanks it works now.

"You can also use the Python lib2to3 package to automatically convert code directly from Python 2.x to Python 3.x. That way, it is possible to write your code in 2.x, then convert it to a format Blender understands (3.x).

This package comes installed with newer forms of Python under the Tools/scripts directory. You can use it to convert a single file by typing $ 2to3 example.py at the command prompt.

There are a variety of different options built in with this package to make this a quite powerful package. It is described in full, glorious detail at http://docs.python.org/2/library/2to3.html, for those who are interested in learning more." -quote Gwenn

LabJack Support
labjack support's picture
The setup script will install

The setup script will install the module files from LabJackPython-5-26-2015/src to your Python's lib/site-packages directory. At the very least for the U3 you should copy over the u3.py, LabJackPython.py and Modbus.py files to lib/site-packages.

Also, if Blender has a Python executable, you could with that executable try running from the LabJackPython directory "/<path_to_blender_python>/python setup.py install".

CorX7
CorX7's picture
I updated your python scripts

I updated your python scripts to version Python3.4. It was trivial with only ~20 changes. I can now use my new engine Blender2.76. LabJack is the best quality equipment on the market. Thanks for all the help.

Final fix:::

Drag all files that the original setup.py installs to Python2.7 site-packages into Blenders 2.76 python site-packages (this includes the egginfo file).

Also I put the files into C:\Program Files\Blender Foundation\Blender\2.76\python\lib

LabJackPython.py (edited manually but the fixes were so simple 2to3 would not have had any problem) now up to version Python3.4

File Attachment: 
LabJack Support
labjack support's picture
Thanks for posting the file

Thanks for posting the file and the helpful information for Blender users.

LabJackPython in its current state on our site and repository are fairly close to being Python 3.x compatible thanks to user commits from the last couple of years.