0

I am trying to develop a program to allow communication between my windows PC and a Raspberry Pi via bluetooth. Things have been moving smoothly on the Pi, but on my PC I cannot seem to get the bluetooth module to work correctly and I haven't seen anyone with the same error message I am getting.

I have pybluez installed, but when I try to import the bluetooth module I get the following error message: module 'socket' has no attribute 'BTPROTO_RFCOMM'. I get this error message when all I run is import bluetooth.

I also tried using sockets but I get the error: module 'socket' has no attribute 'AF_BLUETOOTH'.

I am wondering if I am missing something that is causing my socket module to not work.

martineau
  • 119,623
  • 25
  • 170
  • 301
Kikibm42
  • 1
  • 1
  • There are probably better Bluetooth libraries on Windows 10. If you are doing Bluetooth Classic then Python's Socket library support that https://stackoverflow.com/a/62815818/7721752. If it is Bluetooth Low Energy (BLE) then Bleak might be better https://github.com/hbldh/bleak – ukBaz Jul 18 '22 at 20:39

1 Answers1

0

I solved the problem by making a virtual environment and using conda install pybluez just in the environment. This also only worked in certain python versions for me: 2.7 and > 3.9. I canonly run the code from the command line, but works fine now!

Kikibm42
  • 1
  • 1