pythonpybluez

cannot install pybluez package on windows cmd prompt


I'm trying to install pybluez on windows cmd with pip install pybluez but I keep on getting the same error. Please help me fix this error. (I'm on windows 11)

C:\WINDOWS\system32>pip install pybluez
Collecting pybluez
  Using cached PyBluez-0.23.tar.gz (97 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pybluez
  Building wheel for pybluez (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.10
      creating build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\ble.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\bluez.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\btcommon.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\macos.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\msbt.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\widcomm.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\__init__.py -> build\lib.win-amd64-3.10\bluetooth
      C:\Users\25ray\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\lib2to3_ex.py:36: SetuptoolsDeprecationWarning: 2to3 support is deprecated. If the project still requires Python 2 support, please migrate to a single-codebase solution or employ an independent conversion process.
        warnings.warn(
      Fixing build\lib.win-amd64-3.10\bluetooth\ble.py build\lib.win-amd64-3.10\bluetooth\bluez.py build\lib.win-amd64-3.10\bluetooth\btcommon.py build\lib.win-amd64-3.10\bluetooth\macos.py build\lib.win-amd64-3.10\bluetooth\msbt.py build\lib.win-amd64-3.10\bluetooth\widcomm.py build\lib.win-amd64-3.10\bluetooth\__init__.py
      Skipping optional fixer: buffer
      Skipping optional fixer: idioms
      Skipping optional fixer: set_literal
      Skipping optional fixer: ws_comma
      Fixing build\lib.win-amd64-3.10\bluetooth\ble.py build\lib.win-amd64-3.10\bluetooth\bluez.py build\lib.win-amd64-3.10\bluetooth\btcommon.py build\lib.win-amd64-3.10\bluetooth\macos.py build\lib.win-amd64-3.10\bluetooth\msbt.py build\lib.win-amd64-3.10\bluetooth\widcomm.py build\lib.win-amd64-3.10\bluetooth\__init__.py
      Skipping optional fixer: buffer
      Skipping optional fixer: idioms
      Skipping optional fixer: set_literal
      Skipping optional fixer: ws_comma
      running build_ext
      building 'bluetooth._msbt' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pybluez
  Running setup.py clean for pybluez
Failed to build pybluez
Installing collected packages: pybluez
  Running setup.py install for pybluez ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pybluez did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.10
      creating build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\ble.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\bluez.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\btcommon.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\macos.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\msbt.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\widcomm.py -> build\lib.win-amd64-3.10\bluetooth
      copying bluetooth\__init__.py -> build\lib.win-amd64-3.10\bluetooth
      C:\Users\25ray\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\lib2to3_ex.py:36: SetuptoolsDeprecationWarning: 2to3 support is deprecated. If the project still requires Python 2 support, please migrate to a single-codebase solution or employ an independent conversion process.
        warnings.warn(
      Fixing build\lib.win-amd64-3.10\bluetooth\ble.py build\lib.win-amd64-3.10\bluetooth\bluez.py build\lib.win-amd64-3.10\bluetooth\btcommon.py build\lib.win-amd64-3.10\bluetooth\macos.py build\lib.win-amd64-3.10\bluetooth\msbt.py build\lib.win-amd64-3.10\bluetooth\widcomm.py build\lib.win-amd64-3.10\bluetooth\__init__.py
      Skipping optional fixer: buffer
      Skipping optional fixer: idioms
      Skipping optional fixer: set_literal
      Skipping optional fixer: ws_comma
      Fixing build\lib.win-amd64-3.10\bluetooth\ble.py build\lib.win-amd64-3.10\bluetooth\bluez.py build\lib.win-amd64-3.10\bluetooth\btcommon.py build\lib.win-amd64-3.10\bluetooth\macos.py build\lib.win-amd64-3.10\bluetooth\msbt.py build\lib.win-amd64-3.10\bluetooth\widcomm.py build\lib.win-amd64-3.10\bluetooth\__init__.py
      Skipping optional fixer: buffer
      Skipping optional fixer: idioms
      Skipping optional fixer: set_literal
      Skipping optional fixer: ws_comma
      running build_ext
      building 'bluetooth._msbt' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pybluez

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.


Solution

  • The package on pypi is out of date.

    enter image description here

    You can download the source code https://github.com/pybluez/pybluez and build it by yourself.