1

I'm trying to send and recieve data over bluetoth on my Raspberry Pi 4, via a bluetooth terminal app on my phone. I've found a couple of tutorials (e.g. this and this) which use python scripts involving import bluetooth, but when I try and run them I get:

ModuleNotFoundError: No module named 'bluetooth'

It is in fact the exact same problem as in this question, but the answer and comments given there haven't helped at all. What am I missing?

1
3

The pybluez module isn't under active development according to the repository. It also doesn't use the preferred D-Bus API.

Another alternative is the BlueDot library which has a good Bluetooth Server included in it. There is a blog introducing it:

https://www.stuffaboutcode.com/2017/07/python-bluetooth-rfcomm-client-server.html

5
  • That's useful to know, thank you; the answer above fixed my problem in the short term so I have accepted it, but I will look into BlueDot for a more long term solution. – S. Dunnim Jan 28 at 22:14
  • do you know of any other resources for using the BlueDot raspberry pi server with an android bluetooth terminal that isn't the bluedot app? I like the simplicity of the library but can't get the raspberry pi server to connect to anything other than the BlueDot app itself – S. Dunnim Jan 29 at 18:03
  • 1
  • Thank you, pulseaudio -k as suggested in the github link fixed the problem. Kind of annoying to have to do that every time but at least it's working. Have now accepted this as an answer to my question, thanks again. – S. Dunnim Jan 30 at 11:13
  • 1
    Glad it worked. If you don't need pulseAudio then I'm sure you can remove it (apt remove pulseaudio) or stop it it starting on boot (autospawn = no in /etc/pulse/client.conf) – ukBaz Jan 30 at 11:29
2

On raspbian Buster you need to install:

  1. python3-bluez for python3.*
  2. python-bluez for python2.7

To install it:

sudo apt install python3-bluez

or (for python2):

sudo apt install python-bluez
1
  • 1
    Thank you, it was python3-bluez I was missing it turns out (already had bluez and python-bluez installed) – S. Dunnim Jan 28 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.