Ubuntu安装蓝牙模块pybluez以及问题解决方案【完美解决】

文章目录

  • 简介
  • 问题及解决办法
  • 总结

简介

近期因工程需要在Ubuntu中使用蓝牙远程一些设备。安装Bluetooth的Python第三方软件包pybluez时遇到很多问题,一番折腾后完美解决。此篇博客进行了梳理和总结,供大家参考。

问题及解决办法

  • pip install pybluez安装pybluez出现subprocess-exited-with-errormetadata-generation-failed错误
pip install pybluez

Ubuntu安装蓝牙模块pybluez以及问题解决方案【完美解决】_第1张图片

  • 尝试使用GitHub的渠道进行安装,仍不成功。
pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez

  • 安装setuptools之后,重新执行pip install pybluez出现subprocess-exited-with-errorcommand 'gcc' failed with exit status 1 错误。原因是因为没有bluetooth/bluetooth.h这个文件。

  • 通过apt安装bluetooth和libbluetooth-dev,解决因为没有bluetooth/bluetooth.h这个文件而报的错误。
    Ubuntu安装蓝牙模块pybluez以及问题解决方案【完美解决】_第2张图片
    Ubuntu安装蓝牙模块pybluez以及问题解决方案【完美解决】_第3张图片

  • 通过在Github上面直接下载Git仓库然后使用setup.py代码安装成功。

python setup.py install

  • 尝试在另一个Python环境中使用pip命令直接安装出现错误,安装2to3之后仍不成功,直接使用pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez安装成功。

总结

直接使用pip指令安装蓝牙模块pybluez不容易成功,需要提前安装好libbluetooth-dev提供头文件。然后使用pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez安装。若访问不了GitHub仓库的可以使用网上下载好的代码仓库通过python setup.py install指令安装。


收集整理和创作不易, 若有帮助, 请帮忙点赞收藏❤️, 谢谢!✨✨

你可能感兴趣的:(笔记,Linux,ubuntu,linux,运维)