gpt4 book ai didi

python-3.x - 为 Pybluez 安装 GATTlib?

转载 作者:行者123 更新时间:2023-12-03 08:56:11 25 4
gpt4 key购买 nike

我尝试使用 PyBluez 在树莓派上运行低功耗蓝牙示例。

所有示例都需要 gattlib 模块。我收到错误

from gattlib import *
ImportError: No module named gattlib

我尝试安装它:

pip3 install gattlib 

但这不起作用?我无法安装 gattlib?


编辑:这是安装 gattlib 时的输出:

pi@raspberrypi:~ $ pip3 install gattlib
Collecting gattlib
Using cached https://files.pythonhosted.org/packages/be/2f/5b1aecec551b42b59d8b399ad444b5672972efb590ca83d784dbe616a3e1/gattlib-0.20150805.tar.gz
Complete output from command python setup.py egg_info:
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-p365j80d/gattlib/setup.py", line 12, in <module>
"pkg-config --cflags glib-2.0".split()).decode('utf-8')
File "/usr/lib/python3.5/subprocess.py", line 316, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 398, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pkg-config', '--cflags', 'glib-2.0']' returned non-zero exit status 1

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-p365j80d/gattlib/

最佳答案

文档:https://pypi.org/project/gattlib/

首先安装这些依赖项:

pkg-config
libboost-python-dev
libboost-thread-dev
libbluetooth-dev >= 4.101
libglib2.0-dev
python-dev

然后,对于使用 python3 的 gattlib,尝试一下:

pip3 download gattlib
tar xvzf ./gattlib-0.20150805.tar.gz
cd gattlib-0.20150805/
sed -ie 's/boost_python-py34/boost_python-py35/' setup.py
pip3 install .

关于python-3.x - 为 Pybluez 安装 GATTlib?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55178684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com