3

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
Marie. P.
  • 255
  • 1
  • 4
  • 17
  • error with `x86_64-linux-gnu-g++` can means you have to install compiler C/C++ - probably `apt install gcc` – furas Feb 10 '20 at 15:05
  • dependencies shows that you have to use Python 3.7 and you need `libboost-python` and `libboost-thread` version `1.67.0` but it is avaliable in Ubuntu 19.04 - see [libboost-thread1.67.0_1.67.0-13_amd64.deb](https://ubuntu.pkgs.org/19.04/ubuntu-main-amd64/libboost-thread1.67.0_1.67.0-13_amd64.deb.html). I have Linux Mint 19.3 based on Ubuntu 18.04 and can't install `1.67` because it makes conflict with already installed `1.65` – furas Feb 10 '20 at 15:21
  • Do you mean these are only available on Ubuntu 19.04? I know for a fact that I had actually managed to install `gattlib´ on Ubuntu 18.04 before. `sudo apt-get install libboost-1.67.0` does not work for me, though (unable to locate package). `sudo apt-get install libboost-all-dev` returns "already newest version (1.65.1.0ubuntu1). – Marie. P. Feb 10 '20 at 16:58
  • I have the same on Linux Mint (also based on Ubuntu 18.04). I can't find `libboost-1.67.0` with `apt`. When I download it and try to install manually then it shows message about conflict with older version `1.65` so I don't try to replace it. I edited `setup.py` and this way I resolved problem with `libboost-python` because `setup` tried to use `libboost-python37` but I have `libboost-python3-py36` (I found it using `locate libboost-python`) – furas Feb 10 '20 at 17:02

3 Answers3

2

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

furas
  • 134,197
  • 12
  • 106
  • 148
0

You need to install python-dev that contains the header files for the Python C API. The following should do the trick (make sure to replace X with your Python version):

sudo apt-get install python3.X-dev
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
0

With 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

Reference: https://pypi.org/project/gattlib/

NOTE: This didn't work for me!

sudo apt install pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev
森林虎猫
  • 101
  • 1
  • 4