How do i fix Unable to install package pybluez==0.22: error:

i just upgraded to the new home assistant and i get this blue tooth error how do i fix it?

Logger: homeassistant.util.package
Source: util/package.py:107
First occurred: 6:50:36 PM (9 occurrences)
Last logged: 7:00:30 PM

Unable to install package pybluez==0.22: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [19 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-311 creating build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/__init__.py -> build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/widcomm.py -> build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/osx.py -> build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/msbt.py -> build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/btcommon.py -> build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/bluez.py -> build/lib.linux-x86_64-cpython-311/bluetooth copying bluetooth/ble.py -> build/lib.linux-x86_64-cpython-311/bluetooth running build_ext building 'bluetooth._bluetooth' extension creating build/temp.linux-x86_64-cpython-311 creating build/temp.linux-x86_64-cpython-311/bluez gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -DTHREAD_STACK_SIZE=0x100000 -fPIC -I./port3 -I/usr/local/include/python3.11 -c bluez/btmodule.c -o build/temp.linux-x86_64-cpython-311/bluez/btmodule.o error: command 'gcc' failed: No such file or directory [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pybluez ERROR: Could not build wheels for pybluez, which is required to install pyproject.toml-based projects
1 Like

Remove the bluetooth_tracker: entry in your configuration.yaml

It’s deprecated and no longer works.

oh ok does that mean the bluetooth in the raspberry pi is no longer functional and i need a esp32 beside it… or is there a plugin?

@Neil_Brownlee where are you getting that the bluetooth_tracker is deprecated? Nothing in the latest release change log or the bluetooth_tracker integration docs mentions it. There are a couple new issues on Home Assistant Core’s Github for the problem after today’s 2023.06.0 release.

1 Like

pybluez doesn’t work with the latest Python version.

Fine.
And is there an alternative for the bluetooth tracker, that works???

2 Likes

SOLUTION FOR DOCKER USERS ONLY:

Step 1:
For Docker Compose users:
Add the following to the Home Assistant container section of your docker-compose.yaml file

command: /bin/sh -c "apk add gcc musl-dev bluez-dev ; /init"

For Unraid users:
Edit your Home Assistant container and add the following to “Post Arguments” (switch the view to Advanced to see this field)

/bin/sh -c "apk add gcc musl-dev bluez-dev ; /init"

For Portainer users:
Add the following to the “Command” field in the “Advanced container settings” section of your Home Assistant container

/bin/sh -c "apk add gcc musl-dev bluez-dev ; /init"

Step 2:
Download the bluetooth_tracker integration files from the home-assistant GitHub. You can do this by going to https://download-directory.github.io and entering the following into the box:

https://github.com/home-assistant/core/tree/dev/homeassistant/components/bluetooth_tracker

Step 3:
Unzip the download, change the directory name to “bluetooth_tracker” and open it.

Step 4:
Replace everything in the manifest.json file with this:

{
  "domain": "bluetooth_tracker",
  "name": "Bluetooth Tracker",
  "codeowners": [],
  "documentation": "https://www.home-assistant.io/integrations/bluetooth_tracker",
  "iot_class": "local_polling",
  "loggers": ["bluetooth", "bt_proximity"],
  "requirements": ["bt-proximity==0.2.1", "git+https://github.com/pybluez/pybluez.git#pybluez==0.30"],
  "version": "1.0.0"
}

Step 5:
Add the directory to your custom_components directory

Step 6:
Restart Home Assistant and hopefully it works!

EDIT: Removed a step as it’s no longed needed.

EDIT 2: Added Portainer users section to Step 1

12 Likes

I can confirm, this solution works.
Thank You so much

Is this a solution or with the next release of 2023.06.1 you will have to do it again and again?

impossible to make this fix for me :

~ pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez
Collecting pybluez
  Cloning https://github.com/pybluez/pybluez.git to /tmp/pip-install-m15j_iel/pybluez_4d22b1c29d6d4fcfbb9ceb9b062d3595
  Running command git clone --filter=blob:none --quiet https://github.com/pybluez/pybluez.git /tmp/pip-install-m15j_iel/pybluez_4d22b1c29d6d4fcfbb9ceb9b062d3595
  Resolved https://github.com/pybluez/pybluez.git to commit 4d46ce14d9e888e3b0c65d5d3ba2a703f8e5e861
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pybluez
  Building wheel for pybluez (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pybluez (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-311
      creating build/lib.linux-aarch64-cpython-311/bluetooth
      copying bluetooth/macos.py -> build/lib.linux-aarch64-cpython-311/bluetooth
      copying bluetooth/__init__.py -> build/lib.linux-aarch64-cpython-311/bluetooth
      copying bluetooth/ble.py -> build/lib.linux-aarch64-cpython-311/bluetooth
      copying bluetooth/bluez.py -> build/lib.linux-aarch64-cpython-311/bluetooth
      copying bluetooth/msbt.py -> build/lib.linux-aarch64-cpython-311/bluetooth
      copying bluetooth/btcommon.py -> build/lib.linux-aarch64-cpython-311/bluetooth
      running build_ext
      building 'bluetooth._bluetooth' extension
      creating build/temp.linux-aarch64-cpython-311
      creating build/temp.linux-aarch64-cpython-311/bluez
      gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/python3.11 -c bluez/btmodule.c -o build/temp.linux-aarch64-cpython-311/bluez/btmodule.o
      bluez/btmodule.c:20:10: fatal error: Python.h: No such file or directory
         20 | #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
Failed to build pybluez

and in log :

2023-06-08 16:20:12.944 ERROR (SyncWorker_5) [homeassistant.util.package] Unable to install package PyBluez==0.30: ERROR: Could not find a version that satisfies the requirement PyBluez==0.30 (from versions: 0.20, 0.21, 0.22, 0.23)

ERROR: No matching distribution found for PyBluez==0.30

2023-06-08 16:20:12.949 ERROR (MainThread) [homeassistant.config] Platform error: device_tracker - Requirements for bluetooth_tracker not found: ['PyBluez==0.30'].

perhaps it could be fix in the next core version ?

You miss the line:
“apk add gcc musl-dev bluez-dev”
inside the container of homeassistant. Follow precisely all commands.
I’ve just followed the instructions and it works.

No it’s was okay with this command

 ~ pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez
Collecting pybluez
  Cloning https://github.com/pybluez/pybluez.git to /tmp/pip-install-m15j_iel/pybluez_4d22b1c29d6d4fcfbb9ceb9b062d3595
  Running command git clone --filter=blob:none --quiet https://github.com/pybluez/pybluez.git /tmp/pip-install-m15j_iel/pybluez_4d22b1c29d6d4fcfbb9ceb9b062d3595
  Resolved https://github.com/pybluez/pybluez.git to commit 4d46ce14d9e888e3b0c65d5d3ba2a703f8e5e861
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done

but i use HASSIO ,…

With Hassio I don’t know if it is possible to fix, do you have access at a command like: docker ps
?

yes thanks i have sucessfully install pybluez and tracker work fine !

2 Likes

I think so too

Hello,
how to install this solution on a raspberry?
No command pip
Thanks

So, with 2023.6.1 i had to do step 1 again (apk add and pip install)
Not nice

Maybe you need to enter the homeassistant container :
sudo docker exec -it homeassistant /bin/bash

1 Like

@acid115 @miky_italy

I’ve worked out a way for the changes to not be undone with HA docker image updates! Please have a look at my original reply again.

NOTE: In addition to the obvious change to step 1, make sure you don’t miss the change made to the manifest.json file of the custom_component, specifically the requirements line.

1 Like

I get the same error. Are you running HA OS?