Using Python on Cygwin for Windows
Posted 05 March 2010 - 12:21 PM
Posted 05 March 2010 - 12:33 PM
Can the Python build in Cygwin be used to work with LabJack modules on a windows system?
Yes. On Windows, we install Python from ActiveState or from python.org, but there's no reason the Cygwin build won't work.
No matter where it comes from, make sure you have Python 2.5 or higher to use LabJackPython.
Posted 30 September 2014 - 04:34 PM
I've noticed that during import of LabJackPython module that the cygwin python environment identifies the os as POSIX ( ie os.name returns 'posix') which causes it to fall into the Mac/Linux case where it attempts in vain to import the Exodriver dynamic library. It should be loading the UD driver for windows.
Perhaps if the OS check were supplemented to check the value of platform.system() then this case could be correctly handled.
See this page for a nice table of values for both os.name and the return value of platform.system() http://stackoverflow...ndows-in-python
Full disclosure: I am running cygwin-X on Windows 7 on a Parallels virtual machine running on a Mac...
Posted 30 September 2014 - 05:23 PM
We can look into updating the LabJackPython's _loadLibrary function to handle Cygwin properly. In our newer Python wrapper/interface for the LJM driver (currently only supports the T7 and Digit) we do account for Cygwin like so with platform.system() instead of os.name and can apply something similar in LabJackPython:
def _loadLibrary(): """Returns a ctypes pointer to the LJM library.""" import sys try: libraryName = None try: if(sys.platform.startswith("win32") or sys.platform.startswith("cygwin")): #Windows libraryName = "LabJackM.dll" if(sys.platform.startswith("linux")): #Linux libraryName = "libLabJackM.so" if(sys.platform.startswith("darwin")): #Mac OS X libraryName = "libLabJackM.dylib" if libraryName is not None: if libraryName == "LabJackM.dll": return ctypes.WinDLL(libraryName) else: return ctypes.CDLL(libraryName) except Exception: e = sys.exc_info() raise LJMError(errorString = "Cannot load the LJM library " + str(libraryName) + ". " + str(e)) #Unsupported operating system raise LJMError(errorString = "Cannot load the LJM library. Unsupported platform " + sys.platform + ".") except LJMError: ljme = sys.exc_info() print(str(type(ljme)) + ": " + str(ljme)) return None
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users