Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Using Python on Cygwin for Windows


  • Please log in to reply
4 replies to this topic

#1 felis_alpinis

felis_alpinis
  • Members
  • 1 posts

Posted 05 March 2010 - 12:21 PM

Can the Python build in Cygwin be used to work with LabJack modules on a windows system?

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

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.

#3 kooksquad

kooksquad
  • Members
  • 1 posts

Posted 30 September 2014 - 04:34 PM

Hi,

 

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...



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

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()[1]
            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()[1]
        print(str(type(ljme)) + ": " + str(ljme))
        return None


#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 07 October 2014 - 06:29 PM

LabJackPython has been updated to handle Cygwin Python environments:

 

https://github.com/l...k/LabJackPython




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users