在Anaconda Python中缺少socket.AF_BLUETOOTH吗?
作者:互联网
我正在尝试使用socket.AF_BLUETOOTH,如此处所述:https://docs.python.org/3.3/library/socket.html
我在Mac OS X 10.10.2上安装了Python 3.3.5 :: Anaconda 2.1.0(x86_64)
并且套接字模块似乎不包含任何AF_BLUETOOTH引用:
In [1]: import socket
In [2]: socket.AF
socket.AF_APPLETALK socket.AF_INET socket.AF_IPX socket.AF_SNA socket.AF_UNIX
socket.AF_DECnet socket.AF_INET6 socket.AF_ROUTE socket.AF_SYSTEM socket.AF_UNSPEC
有人可以帮忙吗?
解决方法:
文档说:
Depending on the system and the build options, various socket families are supported by this module.
从Modules / socketmodule.c中的这一位开始:
#if (defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)) && !defined(__NetBSD__) && !defined(__DragonFly__)
#define USE_BLUETOOTH 1
您需要确保在编译过程中将HAVE_BLUETOOTH_H或USE_BLUETOOTH设置为true.哪个取决于头文件的位置.它们可以位于/usr/include或/usr/include / bluetooth中.您可以通过以下方式检查当前设置:
import sysconfig
print sysconfig.get_config_vars()['HAVE_BLUETOOTH_H']
我猜当前返回0.来自pyconfig.h.in的提示:
/* Define to 1 if you have the <bluetooth/bluetooth.h> header file. */
#undef HAVE_BLUETOOTH_BLUETOOTH_H
因此,应确保在系统上存在bluetooth / bluetooth.h头文件,并且在编译过程中该头文件在搜索路径中可用.
标签:python-3-x,sockets,anaconda,bluetooth-lowenergy,python 来源: https://codeday.me/bug/20191120/2045181.html