问题
I reinstalled PyBluez some weeks ago since I couldn't get basic functions to work. Now I can't even import it to Python 3.
import bluetooth
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import bluetooth
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyBluez-0.22-py3.6.egg/bluetooth/__init__.py", line 47, in <module>
from .osx import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyBluez-0.22-py3.6.egg/bluetooth/osx.py", line 1, in <module>
import lightblue
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lightblue/__init__.py", line 160, in <module>
from _lightblue import *
ModuleNotFoundError: No module named '_lightblue'
I was not able to install pybluez via pip/pip3, however I was able to install it by downloading the Github project. I have tried to update it, all suggestions I could find on matter online and much more.
I appreciate any help I can get.
回答1:
This is the closed OS X import issue #108 on GitHub: http://github.com/karulis/pybluez/issues/108
It's actually quite an old issue. What version are you on? El Captain?
One thing the author suggested you might do is remove your current installation and install the GitHub repo using pip:
git clone https://github.com/karulis/pybluez.git
pip install -e pybluez
That seemed to get the import working for the OP of the GitHub issue, but there were still some bugs due to limited support of OS X. You can read more about the bugs and troubleshooting on GitHub.
来源:https://stackoverflow.com/questions/46017374/cannot-import-bluetooth-in-python-3-osx