Missing socket.AF_BLUETOOTH in Anaconda Python?

后端 未结 2 940
轻奢々
轻奢々 2021-01-13 15:33

I\'m trying to use socket.AF_BLUETOOTH as explained here: https://docs.python.org/3.3/library/socket.html

I have Python 3.3.5 :: Anaconda 2.1.0 (x86_64) on Mac OS X

2条回答
  •  伪装坚强ぢ
    2021-01-13 15:44

    The docs say:

    Depending on the system and the build options, various socket families are supported by this module.

    And from this bit in Modules/socketmodule.c:

    #if (defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)) && !defined(__NetBSD__) && !defined(__DragonFly__)
    #define USE_BLUETOOTH 1
    

    you'll want to make sure that HAVE_BLUETOOTH_H or USE_BLUETOOTH get set true during compilation. Which one depends by the location of your headers file. They can be in /usr/include or /usr/include/bluetooth. You can check your current settings via:

    import sysconfig
    print sysconfig.get_config_vars()['HAVE_BLUETOOTH_H']
    

    I'm guessing that returns 0 for you currently. A hint from pyconfig.h.in:

    /* Define to 1 if you have the  header file. */
    #undef HAVE_BLUETOOTH_BLUETOOTH_H
    

    so you should make sure that bluetooth/bluetooth.h header file is present on your system and available in your search path during compilation.

提交回复
热议问题