Python3错误“;没有名为bluetooth的模块;关于LinuxMint
我正在尝试通过蓝牙将我的联想S10E连接到任天堂Wiimote。我使用的是一个简单的Python脚本,如下所示。我使用Python3错误“;没有名为bluetooth的模块;关于LinuxMint,python,linux,python-3.x,module,bluetooth,Python,Linux,Python 3.x,Module,Bluetooth,我正在尝试通过蓝牙将我的联想S10E连接到任天堂Wiimote。我使用的是一个简单的Python脚本,如下所示。我使用python3find\uwii.py从LinuxMint(版本16,“Petra”)命令行调用它 脚本: import bluetooth target_name = "Nintendo RVL-CNT-01" target_address = "00:1C:BE:29:75:7F" nearby_devices = bluetooth.discover_devices()
python3find\uwii.py从LinuxMint(版本16,“Petra”)命令行调用它
脚本:
import bluetooth
target_name = "Nintendo RVL-CNT-01"
target_address = "00:1C:BE:29:75:7F"
nearby_devices = bluetooth.discover_devices()
for bdaddr in nearby_devices:
if target_name == bluetooth.lookup_name( bdaddr ):
target_address = bdaddr
break
if target_address is not None:
print("found target bluetooth device with address "), target_address
else:
print("could not find target bluetooth device nearby")
我收到了错误
Traceback (most recent call last):
File "find_wii.py", line 1, in <module>
import bluetooth
ImportError: No module named 'bluetooth'
回溯(最近一次呼叫最后一次):
文件“find_wii.py”,第1行,在
导入蓝牙
ImportError:没有名为“bluetooth”的模块
我已经为它安装了bluez和python包装(sudo aptitude install python bluez
)。我已经升级了我的系统(sudo-apt-get-update
,sudo-apt-get-update
)。我确实咨询过谷歌,我能找到的唯一官方bug是和,这两个答案对我都不起作用
如何使蓝牙模块工作 您已经安装了Python 2版本的bluez绑定。使用python2
运行脚本或安装python3绑定。由于它们没有打包,您需要使用pip安装它们:
python3 -m pip install pybluez
对于Ubuntu 16.04,我也有同样的问题。我安装了pybluez,解决了导入问题。我使用以下方式安装它:
sudo pip3 install pybluez
这在raspberry pi 3上对我有效。顺便说一句,这是错误的(至少对于Python 3):print(“找到带地址的目标蓝牙设备”)、target\u address
@otus,感谢您捕捉到这一点!看起来您已经编辑了该脚本,其中target\u address
被初始化为None
。如果这是一个函数,target\u name
将是一个参数,但target\u address
不会;它将是一个工作变量和最终返回值。此代码为用户发现该地址;你不应该自己填写。这给了我importorror:libbluetooth.so.3:无法打开共享对象文件:没有这样的文件或目录
,由sudo apt get install libbluetooth3
修复。1944年4月14日的Debian 9.0 You@otus拯救了我的noobie生命。这在没有bluetooth
、libbluetooth dev
软件包的情况下起作用,但与后者相关的是libbluetooth3
。在sudopip3安装pybluez
和pip3安装pybluez
导致以下错误后,bluez/btmodule.h:5:10:致命错误:bluetooth/bluetooth.h:没有这样的文件或目录
。
sudo apt-get install bluetooth libbluetooth-dev
sudo python3 -m pip install pybluez