TheWeirdDev / Bluetooth_Headset_Battery_Level

A python script to get battery level from Bluetooth headsets
GNU General Public License v3.0
760 stars 83 forks source link

error: command '/usr/bin/gcc' failed with exit code 1 #85

Open meetdilip opened 1 year ago

meetdilip commented 1 year ago

Thanks for the helpful library. Appreciate the hard work.

My Blaupunkt SBA 20 shows battery percentage in Windows 10 but not in Ubuntu 22.04

I tried everything to fix the Device or Resource busy

https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level/issues/77#issue-1169236587

including using bluetoothctl and GUI to disconnect and connect my Blaupunkt SBA 20 before running the script. Then changed setuptools == 58

https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level/issues/83

And then tried the command to install pybluez as in

https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level/issues/78

but I get this error

dilip@dilip-pc:~$ pip install PyBluez
Defaulting to user installation because normal site-packages is not writeable
Collecting PyBluez
  Using cached PyBluez-0.23.tar.gz (97 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: PyBluez
  Building wheel for PyBluez (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [26 lines of output]
      /snap/blender/2661/3.2/python/lib/python3.10/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_2to3'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.10
      creating build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/macos.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/msbt.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/__init__.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/widcomm.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/btcommon.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/bluez.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/ble.py -> build/lib.linux-x86_64-3.10/bluetooth
      running build_ext
      building 'bluetooth._bluetooth' extension
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/bluez
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/sqlite/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/bzip2/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/lzma/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/zlib/include -fPIC -fPIC -fPIC -I./port3 -I/snap/blender/2661/3.2/python/include/python3.10 -c bluez/btmodule.c -o build/temp.linux-x86_64-3.10/bluez/btmodule.o
      In file included from bluez/btmodule.c:20:
      bluez/btmodule.h:4:10: fatal error: Python.h: No such file or directory
          4 | #include "Python.h"
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyBluez
  Running setup.py clean for PyBluez
Failed to build PyBluez
Installing collected packages: PyBluez
  Running setup.py install for PyBluez ... error
  error: subprocess-exited-with-error

  × Running setup.py install for PyBluez did not run successfully.
  │ exit code: 1
  ╰─> [26 lines of output]
      /snap/blender/2661/3.2/python/lib/python3.10/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_2to3'
        warnings.warn(msg)
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.10
      creating build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/macos.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/msbt.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/__init__.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/widcomm.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/btcommon.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/bluez.py -> build/lib.linux-x86_64-3.10/bluetooth
      copying bluetooth/ble.py -> build/lib.linux-x86_64-3.10/bluetooth
      running build_ext
      building 'bluetooth._bluetooth' extension
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/bluez
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/sqlite/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/bzip2/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/lzma/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/zlib/include -fPIC -fPIC -fPIC -I./port3 -I/snap/blender/2661/3.2/python/include/python3.10 -c bluez/btmodule.c -o build/temp.linux-x86_64-3.10/bluez/btmodule.o
      In file included from bluez/btmodule.c:20:
      bluez/btmodule.h:4:10: fatal error: Python.h: No such file or directory
          4 | #include "Python.h"
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> PyBluez

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
TheWeirdDev commented 1 year ago

Hi, You need to install python3-dev package.

meetdilip commented 1 year ago

Hi, thanks for the reply. Looks like it is already installed

image