python使用蓝牙库选择

news2024/10/7 8:27:29

蓝牙库选择

pybluez

项目地址:https://github.com/pybluez/pybluez
文档地址:https://pybluez.readthedocs.io/en/latest/index.html
蓝牙支持:经典蓝牙 / BLE蓝牙【仅Linux】
平台支持:

LinuxRaspberry PimacOSWindows
✔️✔️✔️✔️

bluepy

项目地址:https://github.com/IanHarvey/bluepy
蓝牙支持:BLE蓝牙【仅Linux】
平台支持:Linux

gatt-python

项目地址:https://github.com/getsenic/gatt-python
蓝牙支持:BLE蓝牙【仅Linux】
平台支持:Linux

PySide6.QtBluetooth

Qt for Python的蓝牙,文档 https://doc.qt.io/qtforpython-6/PySide6/QtBluetooth/index.html
蓝牙支持 / 平台支持:
在这里插入图片描述

bleak

项目地址:https://github.com/hbldh/bleak
文档地址:https://bleak.readthedocs.io/en/latest/
蓝牙支持:BLE蓝牙【windows 10/Linux】
平台支持:

  • Supports Windows 10, version 16299 (Fall Creators Update) or greater
  • Supports Linux distributions with BlueZ >= 5.43 (See Linux backend for more details)
  • OS X/macOS support via Core Bluetooth API, from at least OS X version 10.11

pybluez安装

pip安装

pip install pybluez

具体安装细节详见 https://github.com/pybluez/pybluez/blob/master/docs/install.rst

常见错误

错误一:使用废弃的 use_2to3 报错

安装错误

$ pip install --upgrade pybluez
Collecting pybluez
  Using cached PyBluez-0.23.tar.gz (97 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in PyBluez setup command: use_2to3 is invalid.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

错误原因详见:PyBluez Issues#431
解决方案:使用如下命令从源代码安装

pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez

错误二:源码安装没有对应的Microsoft Visual C++ 14.0库

$ pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez
Collecting pybluez
  Cloning https://github.com/pybluez/pybluez.git to c:\users\acer\appdata\local\temp\pip-install-mki8zoy9\pybluez_5660e54d6b4643c2a85546348792a2ee
  Running command git clone --filter=blob:none --quiet https://github.com/pybluez/pybluez.git 'C:\Users\acer\AppData\Local\Temp\pip-install-mki8zoy9\pybluez_5660e54d6b4643c2a85546348792a2ee'
  Resolved https://github.com/pybluez/pybluez.git to commit 4d46ce14d9e888e3b0c65d5d3ba2a703f8e5e861
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pybluez
  Building wheel for pybluez (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pybluez (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\bluetooth
      copying bluetooth\ble.py -> build\lib.win-amd64-cpython-311\bluetooth
      copying bluetooth\bluez.py -> build\lib.win-amd64-cpython-311\bluetooth
      copying bluetooth\btcommon.py -> build\lib.win-amd64-cpython-311\bluetooth
      copying bluetooth\macos.py -> build\lib.win-amd64-cpython-311\bluetooth
      copying bluetooth\msbt.py -> build\lib.win-amd64-cpython-311\bluetooth
      copying bluetooth\__init__.py -> build\lib.win-amd64-cpython-311\bluetooth
      running build_ext
      building 'bluetooth._msbt' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pybluez
Failed to build pybluez
ERROR: Could not build wheels for pybluez, which is required to install pyproject.toml-based projects

解决方式:从https://visualstudio.microsoft.com/visual-cpp-build-tools/下载Microsoft C++ 生成工具安装后重新执行指令。

在这里插入图片描述

$ pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez
Collecting pybluez
  Cloning https://github.com/pybluez/pybluez.git to c:\users\acer\appdata\local\temp\pip-install-n2w1b_hj\pybluez_e8804231d731412e974e0d8e7a4a56f4
  Running command git clone --filter=blob:none --quiet https://github.com/pybluez/pybluez.git 'C:\Users\acer\AppData\Local\Temp\pip-install-n2w1b_hj\pybluez_e8804231d731412e974e0d8e7a4a56f4'
  Resolved https://github.com/pybluez/pybluez.git to commit 4d46ce14d9e888e3b0c65d5d3ba2a703f8e5e861
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pybluez
  Building wheel for pybluez (pyproject.toml) ... done
  Created wheel for pybluez: filename=PyBluez-0.30-cp311-cp311-win_amd64.whl size=38986 sha256=a37ebad09bb1196f44d7a90900694c0ac1802c83efef5d3766a908dc6b23fd84
  Stored in directory: C:\Users\acer\AppData\Local\Temp\pip-ephem-wheel-cache-dtnnjqfc\wheels\99\fe\57\0c682c42e37c808dc69125bf83b302f94976743c8cb038a845      
Successfully built pybluez
Installing collected packages: pybluez
Successfully installed pybluez-0.30

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1041067.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

本地搭建kafka并用java实现发送消费消息

1、下载kafka的jar包文件 https://www.apache.org/dyn/closer.cgi?path/kafka/3.1.0/kafka_2.12-3.1.0.tgz2、下载完成直接操作命令启动 1、打开新的terminal(终端)窗口,进入kafka的bin目录 启动zk./zookeeper-server-start.sh ../config/zookeeper.properties2、…

bash中执行比较的几种方法

bash 脚本中的 test 命令用于检查表达式的有效性,检查命令或表达式为 true 或者 false。此外,它还可以用于检查文件的类型和权限。 如果命令或表达式有效,则 test 命令返回0,否则返回1。 使用 test 命令 test 命令的基本语法如…

速卖通数据分析怎么看?速卖通数据分析工具有哪些?—站斧浏览器

速卖通数据分析怎么看? 1、关注销售指标:在进行速卖通数据分析时,卖家应特别关注销售指标,如销售额、订单量、转化率等。通过对这些指标的分析,卖家可以了解到自己店铺的销售状况以及变化趋势,进而采取相应…

【postgresql】 ERROR: multiple assignments to same column “XXX“

Cause: org.postgresql.util.PSQLException: ERROR: multiple assignments to same column "XXX"; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: multiple assignments to same column "XXX"; 原因:or…

SpringCloud Gateway--Predicate/断言(详细介绍)中

😀前言 本篇博文是关于SpringCloud Gateway–Predicate/断言(详细介绍)中,希望你能够喜欢 🏠个人主页:晨犀主页 🧑个人简介:大家好,我是晨犀,希望我的文章可以…

GraalJS及平台JS脚本能力建设

GraalJS及平台JS脚本能力建设 GraalJS替换Nashorn Oracle宣布弃用Nashorn Javascript引擎,最终将从未来所有的JDK中删除。 Nashorn最初是在JDK 8中引入的,用于取代Rhino脚本引擎。发布时,Nashorn是ECMAScript-262 5.1的完整实现&#xff0…

服务接口调用OpenFeign_日志增强

OpenFeign虽然提供了日志增强功能,但是默认是不显示任何日志的,不过开发者在调试阶段可以自己配置日志的级别。 OpenFeign的日志级别如下: NONE:默认的,不显示任何日志;BASIC:仅记录请求方法、URL、响应状…

CMU15-213 课程笔记 04-Floating Point

文章目录 浮点数如何用二进制表示IEEE 浮点数标准IEEE 浮点数实现IEEE 浮点数在内存里 E exp - bias 计算指数M 1.xxx 尾数计算举例:对一个浮点数进行转换一些关于浮点数的计算等等 浮点数如何用二进制表示 计算机内部的浮点数不是这样存在内存里的(至…

解决vs2022项目文件夹内.vs文件夹容量虚高问题

打开系统显示隐藏文件夹 会在vs2022的项目文件夹内有一个.vs文件夹 在子目录里会有一个Browse.VC.db文件,我的项目代码只有120m,而这个db文件居然有70m 而且每次打开vs项目,会使这个文件发生容量变化,如果你的git项目恰好包含这个.vs文件夹,那就比较不爽了,每次都要更新这个文件…

Python中的设计模式 -- 单例

迷途小书童 读完需要 2分钟 速读仅需 1 分钟 当我们谈到单例模式时,可以想象一个非常特殊的餐厅,这个餐厅只有一个桌子,无论多少人来用餐,都只能坐在这个桌子上。这个桌子就是餐厅的单例,它保证了整个餐厅中只有一个桌…

数据结构学习笔记——查找算法中的树形查找(平衡二叉树)

目录 一、平衡二叉树的定义二、平衡因子三、平衡二叉树的插入和构造(一)LL型旋转(二)LR型旋转(三)RR型旋转(四)RL型旋转 四、平衡二叉树的删除(一)叶子结点&a…

进行 XSS 攻击 和 如何防御

跨站脚本攻击(XSS 攻击)是 Web 开发中最危险的攻击之一。以下是它们的工作原理以及防御方法。 XSS 攻击 跨站脚本攻击就是在另一个用户的计算机上运行带有恶意的 JS 代码。假如我们的程序没有对这些恶意的脚本进行防御的话,他们就会由我们的…

【刷题笔记9.25】LeetCode:相交链表

LeetCode:相交链表 一、题目描述 给你两个单链表的头节点 headA 和 headB ,请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点,返回 null 。 二、分析及代码 方法一:使用哈希Set集合 (注意…

安装ipfs-swarm-key-gen

安装ipfs-swarm-key-gen Linux安装go解释器安装ipfs-swarm-key-gen Linux安装go解释器 https://blog.csdn.net/omaidb/article/details/133180749 安装ipfs-swarm-key-gen # 编译ipfs-swarm-key-gen二进制文件 go get -u github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm…

机器学习(19)---神经网络详解

神经网络 一、神经网络概述1.1 神经元模型1.2 激活函数 二、感知机2.1 概述2.2 实现逻辑运算2.3 多层感知机 三、神经网络3.1 工作原理3.2 前向传播3.3 Tensorflow实战演示3.3.1 导入数据集查看3.3.2 数据预处理3.3.3 建立模型3.3.4 评估模型 四、反向传播五、例题5.1 题15.2 题…

Qt/C++音视频开发56-udp推流和拉流/组播和单播推流

一、前言 之前已经实现了rtsp/rtmp推流,rtsp/rtmp/hls/flv/ws-flv/webrtc等拉流,这种一般都需要依赖一个独立的流媒体服务程序,有没有一种更便捷的方式不需要这种依赖,然后又能实现推拉流呢,当然有的那就是udpp推流&a…

Linux DataEase数据可视化分析工具结合cpolar实现远程访问

文章目录 前言1. 安装DataEase2. 本地访问测试3. 安装 cpolar内网穿透软件4. 配置DataEase公网访问地址5. 公网远程访问Data Ease6. 固定Data Ease公网地址 前言 DataEase 是开源的数据可视化分析工具,帮助用户快速分析数据并洞察业务趋势,从而实现业务…

2023-油猴(Tampermonkey)脚本推荐

2023-油猴(Tampermonkey)脚本推荐 知乎增强 链接 https://github.com/XIU2/UserScript https://greasyfork.org/zh-CN/scripts/419081 介绍 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回…

HTML+CSS综合案例二:CSS简介

<!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title> CSS简介</title><style>h1{color: #33…

Linux安装Mysql主从集群(图文解说详细版)

MySQL主从集群是一种数据库架构模式&#xff0c;由一个主数据库&#xff08;Master&#xff09;和多个从数据库&#xff08;Slave&#xff09;组成。在主从集群中&#xff0c;主数据库负责处理写操作&#xff08;如插入、更新、删除&#xff09;&#xff0c;而从数据库则用于读…