Can't import lightblue with Macport or Homebrew Python and 3.0.x PyObjC

Issue #111 resolved
Guido Sanchez
created an issue

I am writing a Python application that uses bluetooth communication with a Lego NXT Mindstorms robot. I had PyObjC 2.5.1 from Macports installation with lightblue 0.4 installed following the instructions in [1], everything worked fine. After upgrading Macports PyObjC to version 3.0.1, when I try to import lightblue I get the following error:

_bridgesupport.py:643: RuntimeWarning: Error parsing BridgeSupport data for IOBluetooth: PyObjCRT_SkipTypeSpec: Got '0x29' at end of union encoding, expecting '0x29' warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)

Reverting PyObjC to version 2.5.1 using Macports solves the issue.

I tried using a clean Homebrew installation with PyObjC 3.0.4 installed using pip with the same results:

/usr/local/lib/python2.7/site-packages/objc/_bridgesupport.py:643: RuntimeWarning: Error parsing BridgeSupport data for IOBluetooth: PyObjCRT_SkipTypeSpec: Got '0x29' at end of union encoding, expecting '0x29' warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)

The only Google search that I found with the same error [2] says that using OS X native Python works, haven't tried that yet.

I don't know what could be the issue but I am willing to help to find this out if you point me in some direction.

Thanks for the amazing work!

[1] http://forums.getpebble.com/discussion/13325/importerror-no-module-named-lightblue-on-mac-os-mavericks [2] https://github.com/obb770/musci/issues/1

Comments (5)

  1. Guido Sanchez reporter

    I did some debugging in order to try to find out the line generating the error. If I run:

    import objc
    __bundle__ = objc.initFrameworkWrapper("IOBluetooth", \
    frameworkIdentifier="com.apple.IOBluetooth",\
    frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOBluetooth.framework"),\
    globals=globals())
    

    I get the error:

    opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/objc/_bridgesupport.py:643: RuntimeWarning: Error parsing BridgeSupport data for IOBluetooth: PyObjCRT_SkipTypeSpec: Got '0x29' at end of union encoding, expecting '0x29'
      warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
    

    While debugging with PyCharm, it seems that the function _parseBridgeSupport located in _bridgesupport.py is the one generating the error. The variable e which contains the error contains:

    args: = {tuple} ("PyObjCRT_SkipTypeSpec: Got '0x29' at end of union encoding, expecting '0x29'",)
    message = {str} 'PyObjCRT_SkipTypeSpec: Got \\'0x29\\' at end of union encoding, expecting \\'0x29\\''
    

    I am running OS X Mavericks and using python 2.7.9 from Macports with PyObjC 3.0.1 installed with the port utility. On the other Macbook, OS X Yosemite and the Python version provided by Homebrew with PyObjC 3.0.4 installed with Pip.

    Thanks again, hope this helps.

  2. Log in to comment