无法安装`gattlib`

Unable to install `gattlib`

我正在尝试在 Python 中安装 gattlib 以便使用它的一些蓝牙工具。

OS 是 ubuntu 18.04.4 LTS。

我现在已经尝试了以下方法(例如 here):

sudo apt-get install mercurial
hg clone https://bitbucket.org/OscarAcena/pygattlib
cd pygattlib
cat DEPENDS
sudo apt-get install libboost-thread-dev libboost-python-dev    libbluetooth-dev libglib2.0-dev python-dev
sudo python3 setup.py install

这给出(我的 Python 是 3.6.9):

usr/bin/ld: cannot find -lboost-python36
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1

此外,我试过:

sudo apt install python3-gattlib

给出:

the following packages have unmet dependencies:
python3-gattlib: Depends: python3 (>= 3.7~) but 3.6.7-1~18.04 is to be installed
                 Depends: libboost-python1.67.0 but is is not installable
                 Depends: libboost-thread1.67.0 but is is not installable

尽管 libboost-python 和 libboost-thread 在第一次尝试中成功安装(见上文),并且 python3 返回 Python 3.6.9.

pip3 install gattlib

显示:

Building wheel for gattlib(setup.py) ... error

Running setup.py install for gattlib ... error

这与我从 (following instructions from this question):

得到的结果完全相同
sudo pip3 download gattlib  
sudo tar xvzf ./gattlib-0.20200122.tar.gz
cd gattlib-0.20200122/
sudo sed -ie 's/boost_python-py34/boost_python36/' setup.py
pip3 install .

我理解这是在 运行 之前对安装文件进行必要的调整,因为,如果我理解正确的话,python 版本在某种程度上被错误地硬编码在那里。

我尝试了更多但没有帮助的事情:

pip3 install --upgrade setuptools
sudo apt-get install python3.6-dev libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
sudo apt-get install libpython-dev
sudo apt-get install libevent-dev
sudo pip3 install gattlib
wget -qO- http://pike.esi.uclm.es/add-pike-repo.sh | sudo sh
sudo apt update
sudo apt install python3-gattlib
sudo apt-get install libbluetooth-dev
pip3 install --upgrade pip
sudo apt-get install mercurial
pip3 install gattlib
sudo apt-get install libboost-all-dev

cd /usr/lib/x86-64-linux-gnu
sudo ln -s libboost_python-py35.so libboost_python-py36.so

sudo apt-get install libbluetooth-dev bluez bluez-hcidump libboost-python-dev libboost-thread-dev libglib2.0-dev

hg clone https://bitbucket.org/OscarAcena/pygattlib
cd pygattlib
cat DEPENDS
sudo apt-get install libboost-thread-dev libboost-python-dev    libbluetooth-dev libglib2.0-dev python-dev
sudo python3 setup.py install
sudo python setup.py install

pip3 install gTTS

sudo apt-get install python3 python-dev python3-dev \
build-essential libssl-dev libffi-dev \
libxml2-dev libxslt1-dev zlib1g-dev \
python-pip
sudo apt-get install aptitude
sudo aptitude install libboost-all-dev

您需要安装 python-dev,其中包含 Python C API 的头文件。以下应该可以解决问题(确保将 X 替换为您的 Python 版本):

sudo apt-get install python3.X-dev

我运行

sudo python3 setup.py install

我也收到错误

usr/bin/ld: cannot find -lboost-python36

因为我没有 boost-python36.aboost-python3-py36.a

(我使用 locate boost-python3 找到了这个文件,它使用带文件名的数据库,因此它比 find 运行得更快,但它可能不会默认安装)

我不得不编辑 setup.py 并更改

boost_libs = ["boost_python3"+str(sys.version_info.minor)]

boost_libs = ["boost_python3-py36"]

或更通用

boost_libs = ["boost_python3-py3"+str(sys.version_info.minor)]

测试 od Linux Mint 19.3 Tricia 基于 Ubuntu 18.04

与 ubuntu 20.04:

$ wget https://github.com/oscaracena/pygattlib/releases/download/v.20201113/python3-gattlib_0.20201113-1_amd64.deb

$ sudo apt install ./python3-gattlib*.deb

$ pip3 install gattlib

参考: https://pypi.org/project/gattlib/

注意:这对我不起作用!

sudo apt install pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev