3

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

操作系统是 ubuntu 18.04.4 LTS。

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

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

这与我得到的结果完全相同(按照这个问题的说明):

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
4

3 回答 3

2

我跑

sudo python3 setup.py install

我也得到错误

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

因为我没有boost-python36.a但是boost-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)]

基于 Ubuntu 18.04 测试 od Linux Mint 19.3 Tricia

于 2020-02-10T17:35:41.027 回答
0

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

sudo apt-get install python3.X-dev
于 2020-02-10T15:07:56.223 回答
0

使用 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
于 2021-12-10T05:22:35.530 回答