为Pybluez安装GATTlib?

时间:2019-03-15 08:48:00

标签: python-3.x bluetooth

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

2 个答案:

答案 0 :(得分:0)

我也有这个。我认为这里似乎缺少一些依赖项:

https://bitbucket.org/OscarAcena/pygattlib/src/a858e8626a93cb9b4ad56f3fb980a6517a0702c6/DEPENDS?at=default&fileviewer=file-view-default

对我来说,即使安装了它们,我也无法成功安装。我使用了一个替代软件包:

pip3 install pygattlib

答案 1 :(得分:0)

先安装这些依赖:

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

然后,对于 gattlib 和 python3,试试:

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 .