pythoninstallationpackageaptgattlib

Unable to install `gattlib`


I am trying to install gattlib in Python in order to use some of its Bluetooth-tools.

The OS is ubuntu 18.04.4 LTS.

I have by now tried the following (as e.g. 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

which gives (my Python is 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

Also, I tried:

sudo apt install python3-gattlib

which gives:

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

despite libboost-python and libboost-thread being successfully installed in the first attempt (see above), and python3 returning Python 3.6.9.

pip3 install gattlib

shows:

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

Running setup.py install for gattlib ... error

Which is the exact same result that I get from (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 .

in which I understand to be a necessary adjustment of the installation file before running it, because, if I understood correctly, the python version is somehow wrongly hardcoded in there.

Futher things I tried and that did not help:

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

Solution

  • I run

    sudo python3 setup.py install
    

    and I also get error

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

    because I don't have boost-python36.a but boost-python3-py36.a.

    (I found this file using locate boost-python3 which uses database with filenames so it works faster then find but it may not be installed as default)

    I had to edit setup.py and change

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

    to

    boost_libs = ["boost_python3-py36"]
    

    or more universal

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

    Tested od Linux Mint 19.3 Tricia based on Ubuntu 18.04