EEVblog® Electronics Community Forum

Electronics => Microcontrollers => Topic started by: conducteur on March 15, 2019, 12:09:22 pm

Title: installing gattlib for python3?
Post by: conducteur on March 15, 2019, 12:09:22 pm
Hello,
I try to run the examples for bluetooth low energy in the pybluez module, but they require the gattlib module.

I tried
Code: [Select]
'pip3 install gattlib' but this fails with following error:

Code: [Select]
/usr/bin/ld: cannot find -lboost_python-py34What does this mean and how can i fix it?
Title: Re: installing gattlib for python3?
Post by: legacy on March 15, 2019, 12:22:32 pm
it sounds you need a library, lib_boost_python-py34, which is probably not currently installed  :-//
Title: Re: installing gattlib for python3?
Post by: mrflibble on March 17, 2019, 05:34:26 pm
Quick bit of generic python advice: if you value your time and/or sanity, I suggest you use virtualenvwrapper (https://virtualenvwrapper.readthedocs.io/en/latest/) for all your pip-ing pleasure.

And generic file-xyz-not-found-how-do-I-solve-that advice, assuming you're using ubuntu:
Code: [Select]
apt-file search libboost_python-pyThat apt-file search will  give you a list of candidate files & packages that you're probably looking for. So for example you could get something like this output:
Code: [Select]
libboost-python1.62-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py27.a
libboost-python1.62-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so
libboost-python1.62-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py36.a
libboost-python1.62-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py36.so
libboost-python1.62.0: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.62.0
libboost-python1.62.0: /usr/lib/x86_64-linux-gnu/libboost_python-py36.so.1.62.0
libboost-python1.65-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py27.a
libboost-python1.65-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so
libboost-python1.65-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py36.a
libboost-python1.65-dev: /usr/lib/x86_64-linux-gnu/libboost_python-py36.so
libboost-python1.65.1: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1
Fairly self-explanatory, so nuf said about that.

To install both & update the apt-file db:
Code: [Select]
apt-get install virtualenvwrapper apt-file && apt-file update

As for virtualenvs, read the docs (https://virtualenvwrapper.readthedocs.io/en/latest/) on how to activate it & general mode of operation. And after you have enabled virtualenvs as per the docs, do something like this:
Code: [Select]
mkvirtualenv --python=$(which python3) some-project-involving-pybluez-py3
pip3 install pybluez

That would create a new virtualenv for your project, and install the pybluez python package ... and all it's dependencies.
And all that without fucking up other dependencies of other projects that you might have pip-installed. As bonus feature it also does not clash with system installed python libraries with a conflicting version. Without virtualenvs those are an endless source of fun, enjoyment and teachable moments.

Caveat: mkvirtualenv takes care of python dependencies, not dev packages and such. But usually the "What dev packages should I install?" is answered in the docs, and at least 234786345 random posts (https://gist.github.com/lexruee/fa2e55aab4380cf266fb) or github "my shit doesn't work" bug reports.

Hope that helps.