This guide assumes that you already have Python 3.8+ installed; but, if not, you can install this easily from the Microsoft store. Just search for Python and look for the highest version number.
There are some rather annoying prerequisites that you need to satisfy before you can do the usual
pip install PyBlueZ.
First, you need Visual Studio Build Tools 2019. Download that from Microsoft.
During installation, there are a few options you must select:
- Desktop Development with C++
- Universal Windows Platform build tools
and then on the right side, be sure that you also check:
- Windows 10 SDK
- the latest version of MSVC C++ x64/x86 build tools
Next, you need to be sure that setuptools is installed:
open up PowerShell and run the following command
pip install --force-reinstall setuptools
Lastly it's time to install PyBlueZ! But if you try to use
pip install pybluez it will likely still fail. This is because there are bugs in the latest pip version of PyBlueZ that have been fixed in their GitHub repository and the pip version has not yet been updated. The solution then is to clone the repo from GitHub and to use that.
Navigate your browser over to the PyBlueZ GitHub Repo and clone the repository to your computer. This can be done as simply as following the steps below.
Then open PowerShell and go to that directory and run the following:
pip install .
You Did It!
And that's it. You should now be able to
import Bluetooth in your Python scripts and have fun with your wireless devices per the PyBlueZ Documentation