python-3.x 安装Pybluez的GATTlib?

drnojrws  于 2023-04-13  发布在  Python
关注(0)|答案(3)|浏览(234)

我尝试使用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/
mcdcgff0

mcdcgff01#

文件: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 .
3pvhb19x

3pvhb19x2#

在linux中解决这个问题的方法是

sudo apt-get update
sudo apt-get install libbluetooth-dev libboost-python-dev libboost-thread-dev libglib2.0-dev python-dev
sudo pip install gattlib
qnzebej0

qnzebej03#

我也有这个。我认为它似乎缺乏一些依赖关系:
https://bitbucket.org/OscarAcena/pygattlib/src/a858e8626a93cb9b4ad56f3fb980a6517a0702c6/DEPENDS?at=default&fileviewer=file-view-default
对我来说,即使安装后,我无法成功安装。我使用了一个替代包:

pip3 install pygattlib

相关问题