No module named 'bluetooth' when using python PyBluez library

87 Views Asked by At

I installed PyBluez on my machine. I checked the interpreter setting it shows that PyBluez is there. But when i run the line import bluetooth i get the error

No module named 'bluetooth'

Can anyone suggest a way to fix this. I tried import PyBluez and it did not work either. Here's the image of the setting and the error enter image description here

1

There are 1 best solutions below

0
vgenovpy On

In the image you've uploaded, you're showing that in the CMD, the "correct" library is installed, but you're running the project from Pycharm's terminal, and looking closely, I can see you're using a virtual environment in Pycharm, but it doesn't see to be activated on the CMD.

So, there are lots of ways of achieving this.

Pycharm

  1. Check that venv is activated (you should see (venv) on top)
  2. Run pip freeze to check if all libraries are correctly installed
  3. Run the project again

CMD/ some terminal

  1. Install/activate a venv
python -m venv venv 
venv\Scripts\activate
pip install <whatever you need>

I highly recommend using an external terminal and not to run projects from the IDE + using always a venv