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 in PyBluez setup command: use_2to3 is invalid. #83

Closed loureirorg closed 1 year ago

loureirorg commented 1 year ago

First of all, thank you for the great tool. It is the only thing that works for me to get battery info from my Bluetooth JBL.

I'm trying to install it according to the instructions:

pip3 install bluetooth_battery

But I'm getting this error:

error in PyBluez setup command: use_2to3 is invalid.

I recently migrated to Ubuntu 22.04. I used to use this tool in Ubuntu 20.04 with no issues.


Full error log:

❯ pip3 install bluetooth_battery
Defaulting to user installation because normal site-packages is not writeable
Collecting bluetooth_battery
  Using cached bluetooth_battery-1.3.2.tar.gz (6.2 kB)
  Preparing metadata (setup.py) ... done
Collecting PyBluez
  Using cached PyBluez-0.23.tar.gz (97 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in PyBluez setup command: use_2to3 is invalid.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

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

Looks like this error comes from PyBluez and not my code. You might want to contact them about it. For now downgrading setuptools==58.0.0 might fix the error temporarily.

loureirorg commented 1 year ago

I was able to fix the issue by installing setuptools version 58.

pip3 install setuptools==58
pip3 install bluetooth_battery

I'm not familiar with Python, so I have no idea what setuptools is, nor what the consequences of installing an old version of it are, but I'm glad this worked to install this tool.

Here's where I found this solution: https://stackoverflow.com/questions/69100275/error-while-downloading-the-requirements-using-pip-install-setup-command-use-2

I'm closing this issue for now because it seems to be fixable on the user side, but it would be great to have if someone with time and knowledge could fix this.