pip install PyBluez, error in installation

1.3k Views Asked by At

I want to use the Library bluetooth, for that I want to install PyBluez. But the following error occured:

Running setup.py clean for PyBluez
Failed to build PyBluez
Installing collected packages: PyBluez
    Running setup.py install for PyBluez ... error
    ERROR: Command errored out with exit status 1:
     command: /home/zfcc/Dokumente/pyshimmer/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-frwmijcd/pybluez_cabc8d0dc26f4997970d90ce928e4ce8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-frwmijcd/pybluez_cabc8d0dc26f4997970d90ce928e4ce8/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3mafgo8m/install-record.txt --single-version-externally-managed --compile --install-headers /home/zfcc/Dokumente/pyshimmer/venv/include/site/python3.7/PyBluez
         cwd: /tmp/pip-install-frwmijcd/pybluez_cabc8d0dc26f4997970d90ce928e4ce8/
    Complete output (36 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/btcommon.py -> build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/ble.py -> build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/macos.py -> build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/bluez.py -> build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/widcomm.py -> build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/msbt.py -> build/lib.linux-x86_64-3.7/bluetooth
    copying bluetooth/__init__.py -> build/lib.linux-x86_64-3.7/bluetooth
    /home/zfcc/Dokumente/pyshimmer/venv/lib/python3.7/site-packages/setuptools/lib2to3_ex.py:41: SetuptoolsDeprecationWarning: 2to3 support is deprecated. If the project still requires Python 2 support, please migrate to a single-codebase solution or employ an independent conversion process.
      SetuptoolsDeprecationWarning)
    Fixing build/lib.linux-x86_64-3.7/bluetooth/btcommon.py build/lib.linux-x86_64-3.7/bluetooth/ble.py build/lib.linux-x86_64-3.7/bluetooth/macos.py build/lib.linux-x86_64-3.7/bluetooth/bluez.py build/lib.linux-x86_64-3.7/bluetooth/widcomm.py build/lib.linux-x86_64-3.7/bluetooth/msbt.py build/lib.linux-x86_64-3.7/bluetooth/__init__.py
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    Fixing build/lib.linux-x86_64-3.7/bluetooth/btcommon.py build/lib.linux-x86_64-3.7/bluetooth/ble.py build/lib.linux-x86_64-3.7/bluetooth/macos.py build/lib.linux-x86_64-3.7/bluetooth/bluez.py build/lib.linux-x86_64-3.7/bluetooth/widcomm.py build/lib.linux-x86_64-3.7/bluetooth/msbt.py build/lib.linux-x86_64-3.7/bluetooth/__init__.py
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    running build_ext
    building 'bluetooth._bluetooth' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/bluez
    x86_64-unknown-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -I./port3 -I/home/zfcc/Dokumente/pyshimmer/venv/include -I/usr/include/python3.7m -c bluez/btmodule.c -o build/temp.linux-x86_64-3.7/bluez/btmodule.o
    In Datei, eingebunden von bluez/btmodule.c:20:
    bluez/btmodule.h:5:10: schwerwiegender Fehler: bluetooth/bluetooth.h: Datei oder Verzeichnis nicht gefunden
        5 | #include <bluetooth/bluetooth.h>
          |          ^~~~~~~~~~~~~~~~~~~~~~~
    Kompilierung beendet.
    error: command 'x86_64-unknown-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/zfcc/Dokumente/pyshimmer/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-frwmijcd/pybluez_cabc8d0dc26f4997970d90ce928e4ce8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-frwmijcd/pybluez_cabc8d0dc26f4997970d90ce928e4ce8/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3mafgo8m/install-record.txt --single-version-externally-managed --compile --install-headers /home/zfcc/Dokumente/pyshimmer/venv/include/site/python3.7/PyBluez Check the logs for full command output.

I was searching for simmilar errors and tried some similar cases, but nothing worked. I have also installed bluez from http://www.bluez.org/. I am using Linux Mint 20 Cinnamon. I used the command pip install PyBluez.

All I want is to test, if my device is still connected. Because sometimes the device loses the connection and the Python Skrpt throws an error. To find out the connection status, I wanted to use the librar bluetooth. But if someone has another possibility to check the status of my device it would be fine too. I bind my device with sudo rfcomm bind 0 <Adress>. With hcitool con the terminal found no device why this way of solution didn t work for me:

import subprocess as sp

stdoutdata = sp.getoutput("hcitool con")

if "XX:XX:XX:XX:XX:XX" in stdoutdata.split():
    print("Bluetooth device is connected")

The service bluetooth status is:

~$ service bluetooth status
● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor pre>
     Active: active (running) since Wed 2021-05-19 16:04:15 CEST; 5min ago
       Docs: man:bluetoothd(8)
   Main PID: 740 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 18949)
     Memory: 2.4M
     CGroup: /system.slice/bluetooth.service
             └─740 /usr/local/libexec/bluetooth/bluetoothd

Mai 19 16:04:15 C02L23NB0124 systemd[1]: Started Bluetooth service.
Mai 19 16:04:15 C02L23NB0124 bluetoothd[740]: Starting SDP server
Mai 19 16:04:15 C02L23NB0124 bluetoothd[740]: Bluetooth management interface 1.>
Mai 19 16:04:15 C02L23NB0124 bluetoothd[740]: src/adapter.c:reset_adv_monitors_>
Mai 19 16:04:18 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.50>
Mai 19 16:04:18 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.50>
Mai 19 16:06:28 C02L23NB0124 bluetoothd[740]: Endpoint unregistered: sender=:1.>
Mai 19 16:06:28 C02L23NB0124 bluetoothd[740]: Endpoint unregistered: sender=:1.>
Mai 19 16:06:29 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.80>
Mai 19 16:06:29 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.80>
lines 1-21/21 (END)...skipping...
● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-05-19 16:04:15 CEST; 5min ago
       Docs: man:bluetoothd(8)
   Main PID: 740 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 18949)
     Memory: 2.4M
     CGroup: /system.slice/bluetooth.service
             └─740 /usr/local/libexec/bluetooth/bluetoothd

Mai 19 16:04:15 C02L23NB0124 systemd[1]: Started Bluetooth service.
Mai 19 16:04:15 C02L23NB0124 bluetoothd[740]: Starting SDP server
Mai 19 16:04:15 C02L23NB0124 bluetoothd[740]: Bluetooth management interface 1.14 initialized
Mai 19 16:04:15 C02L23NB0124 bluetoothd[740]: src/adapter.c:reset_adv_monitors_complete() Failed to reset Adv Monitors: Unknown Command (0x01)
Mai 19 16:04:18 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.50 path=/MediaEndpoint/A2DPSink/sbc
Mai 19 16:04:18 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.50 path=/MediaEndpoint/A2DPSource/sbc
Mai 19 16:06:28 C02L23NB0124 bluetoothd[740]: Endpoint unregistered: sender=:1.50 path=/MediaEndpoint/A2DPSink/sbc
Mai 19 16:06:28 C02L23NB0124 bluetoothd[740]: Endpoint unregistered: sender=:1.50 path=/MediaEndpoint/A2DPSource/sbc
Mai 19 16:06:29 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.80 path=/MediaEndpoint/A2DPSink/sbc
Mai 19 16:06:29 C02L23NB0124 bluetoothd[740]: Endpoint registered: sender=:1.80 path=/MediaEndpoint/A2DPSource/sbc

and my bluetooth Version is 5.58

0

There are 0 best solutions below