尝试在macOS上安装PyBlue时出错

时间:2017-02-07 11:23:52

标签: python macos pip

我已完成sudo easy_install pip

现在我尝试使用pyblue

安装库sudo pip install pyblue

这是我遇到的错误:

Password:
Collecting pybluez
  Downloading PyBluez-0.22.zip (109kB)
100% |████████████████████████████████| 112kB 716kB/s 
Installing collected packages: pybluez
  Running setup.py install for pybluez ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-ZBL104/pybluez/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-TidHjG-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-intel-2.7
creating build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/__init__.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/ble.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/bluez.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/btcommon.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/msbt.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/osx.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
copying bluetooth/widcomm.py -> build/lib.macosx-10.12-intel-2.7/bluetooth
running build_ext
building 'bluetooth._osxbt' extension
creating build/temp.macosx-10.12-intel-2.7
creating build/temp.macosx-10.12-intel-2.7/osx
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/IOBluetooth.framework/Headers -I/System/Library/Frameworks/CoreFoundation.framework/Headers -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c osx/_osxbt.c -o build/temp.macosx-10.12-intel-2.7/osx/_osxbt.o
osx/_osxbt.c:676:5: error: unknown type name 'IOBluetoothDeviceInquiryRef'; did you mean 'IOBluetoothDeviceRef'?
    IOBluetoothDeviceInquiryRef inquiry;
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    IOBluetoothDeviceRef
/System/Library/Frameworks/IOBluetooth.framework/Headers/IOBluetoothUserLib.h:34:47: note: 'IOBluetoothDeviceRef' declared here
typedef struct OpaqueIOBluetoothObjectRef *                     IOBluetoothDeviceRef;
                                                                ^
osx/_osxbt.c:688:17: error: unknown type name 'IOBluetoothDeviceInquiryRef'; did you mean 'IOBluetoothDeviceRef'?
                IOBluetoothDeviceInquiryRef inquiryRef,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                IOBluetoothDeviceRef
/System/Library/Frameworks/IOBluetooth.framework/Headers/IOBluetoothUserLib.h:34:47: note: 'IOBluetoothDeviceRef' declared here
typedef struct OpaqueIOBluetoothObjectRef *                     IOBluetoothDeviceRef;
                                                                ^
osx/_osxbt.c:703:19: warning: implicit declaration of function 'IOBluetoothDeviceInquiryCreateWithCallbackRefCon' is invalid in C99 [-Wimplicit-function-declaration]
    dd->inquiry = IOBluetoothDeviceInquiryCreateWithCallbackRefCon (&dd);
                  ^
osx/_osxbt.c:703:17: warning: incompatible integer to pointer conversion assigning to 'IOBluetoothDeviceRef' (aka 'struct OpaqueIOBluetoothObjectRef *') from 'int' [-Wint-conversion]
    dd->inquiry = IOBluetoothDeviceInquiryCreateWithCallbackRefCon (&dd);
                ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
osx/_osxbt.c:705:5: warning: implicit declaration of function 'IOBluetoothDeviceInquirySetCompleteCallback' is invalid in C99 [-Wimplicit-function-declaration]
    IOBluetoothDeviceInquirySetCompleteCallback (dd->inquiry,
    ^
osx/_osxbt.c:717:5: warning: implicit declaration of function 'IOBluetoothDeviceInquiryStart' is invalid in C99 [-Wimplicit-function-declaration]
    IOBluetoothDeviceInquiryStart (dd->inquiry);
    ^
osx/_osxbt.c:721:5: warning: implicit declaration of function 'IOBluetoothDeviceInquiryDelete' is invalid in C99 [-Wimplicit-function-declaration]
    IOBluetoothDeviceInquiryDelete (dd->inquiry);
    ^
5 warnings and 2 errors generated.
error: command 'cc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-ZBL104/pybluez/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-TidHjG-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-ZBL104/pybluez/

不确定发生了什么以及如何解决问题。

使用easy_install似乎给出了类似的错误。

问题:

  • 我应该手动安装pyblue吗?

由于

2 个答案:

答案 0 :(得分:1)

Apple操作系统不支持您尝试使用的Pybluez软件包(已于28-08-2015发布)。

来自pybluez pypi page

  

蓝牙Python扩展模块,允许Python“”开发人员使用   系统蓝牙资源。 PyBluez使用 GNU / Linux和   Windows XP

OSX support was added sometime between that release and September 10th 2015.

在撰写本文时,pybluez仍未使用macOS(OSX 10.12)进行测试,但如果您确实想尝试手动编译,那么您需要the latest source from Github instead

答案 1 :(得分:0)

根据offical doc

  

Mac OS X(不稳定 - 仅在OS X 10.10 / 10.11上测试):

     

Python 2.3或更高版本

     

的Xcode

     

PyObjc 3.1b或更高版本(https://pythonhosted.org/pyobjc/install.html#manual-installation

也许,另一个answer可能会有所帮助。

您可以查看LightBlue,这是跨平台的,但已经过时了。

相关问题