我在用尼科莱·耶戈罗夫的port of LightBlue for OS X 10.8。导入lightblue
模块后,我立即得到以下错误:
Traceback (most recent call last):
File "commander.py", line 3, in <module>
import lightblue
File "/usr/local/lib/python2.7/site-packages/lightblue/__init__.py", line 160, in <module>
from _lightblue import *
File "/usr/local/lib/python2.7/site-packages/lightblue/_lightblue.py", line 397, in <module>
class _AsyncDeviceInquiry(Foundation.NSObject):
TypeError: Error when calling the metaclass bases
class _AsyncDeviceInquiry does not correctly implement protocol IOBluetoothDeviceInquiryDelegate: the signature for method deviceInquiryComplete:error:aborted: is v@:@iB instead of v@:@iZ
似乎版本不匹配。这个问题有已知的解决方法吗?
最佳答案
从Yegorov's repo打开源代码中的文件src/mac/_lightblue.py
。找到第467行(如下所示):
deviceInquiryComplete_error_aborted_ = objc.selector(
deviceInquiryComplete_error_aborted_, signature="v@:@iB")
将字符串
v@:@iB
更改为v@:@iZ
。从此源重新安装LightBlue:cd <lightblue_root> && sudo python setup.py install
这将解决签名错误。
二元的
dlamblin请求使用此修复的二进制文件。这里是my
LightAquaBlue.framework
,使用Python 2.7.4为OS X 10.8.2构建(输入/Library/Frameworks
)。关于python - OS X 10.8上的LightBlue:方法签名不匹配,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15940541/