【安装pybluez】报错解决python setup.py egg_info did not run successfully.
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in PyBluez setup command: use_2to3 is invalid.
[end of output]
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info 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: metadata-generation-failed
正常通过window11 python 3.11安装pybluez,尝试第一次安装过程出现缺少,window SDK,于是去官网下载了SDK.先下载。之后安装,然后下载之后install SDK智能安装到c盘。安装后重新启动依旧出现该问题。
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in PyBluez setup command: use_2to3 is invalid.
经过查找其实就是版本问题,但是现在已经很难匹配了。不能直接通过pip进行识别了,因此本人采取以下办法。
上到pybluez官网,github进行下载。
http://t.csdnimg.cn/CnXRH
这个博主中的地址。
然后解压文件夹。
之后,通过cmd,cd到解压后存在setup.py的位置,并且配置好当前环境。conda activate envir.
之后,正常安装过程。使用语句
python setup.py install
import time
from bluetooth import *
import bluetooth
#列表,用于存放已搜索过的蓝牙名称
alreadyFound = []
#搜索蓝牙
def findDevs():
foundDevs = discover_devices(lookup_names=True)
# 循环遍历,如果在列表中存在的就不打印
for (addr,name) in foundDevs:
if addr not in alreadyFound:
print("[*]蓝牙设备:" + str(name))
print("[+]蓝牙MAC:" + str(addr))
# 新增的设备mac地址定到列表中,用于循环搜索时过滤已打印的设备
alreadyFound.append(addr)
# 循环执行,每5秒执行一次
findDevs()
time.sleep(3)
port = 1
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect(("98:DA:E0:01:1D:9E", port))
message = "$1,0,0,0,0,0,0,0,0,0#"
sock.send(message)
sock.close()
print("send message")
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!