MacOS – How to install a working bluetooth library for Python

bluetoothmacospython

I need to access Bluetooth from Python. I have tried installing lightblue via easy_install. It installs properly, but when I try to import it it fails.

User@Mac:codes$ python
Python 2.7.5 (default, Sep 24 2013, 20:58:05)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lightblue
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/__init__.py", line 160, in <module>
from _lightblue import *
File    "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_lightblue.py", line 23, in <module>
import Foundation
ImportError: No module named Foundation

That means module called "Foundation" does not exist or python cannot find it.
I continued my research and found this. I followed the instructions:

User@Mac:codes$ export PYTHONPATH="/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/"

And tried again:

Python 2.7.5 (default, Sep 24 2013, 20:58:05)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import lightblue

And got this:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File     "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/__init__.py", line 160, in <module>
from _lightblue import *
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_lightblue.py", line 28, in <module>
import _LightAquaBlue
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_LightAquaBlue.py", line 32, in <module>
_FRAMEWORK_PATH)
ImportError: Cannot load LightAquaBlue framework, not found at/Library/Frameworks/LightAquaBlue.framework

And I tried installing python from http://www.python.org.
What can I do anymore?

Best Answer

Why not try python from homebrew. https://brew.sh

This port is very widely updated and has tons of previous versions if you run into a problem or have some modules that break on the latest versions as they do on occasion.