Reference: https://forums.leapmotion.com/forum/support/community-support/os-x/3169-python-pythreadstate-get-no-current-thread
If you try to run Leap Motion with Python introduced by homebrew or built by yourself
python
Fatal Python error: PyThreadState_Get: no current thread
I think that an error like this will appear and it will not work.
This is because the dependency of the object LeapPython.so
, which provides a bridge between Leap's interface and Python, is for Python bundled with the Mac.
I will solve this.
You will need the commands ʻotool and ʻinstall_name_tool
. I think this required X-code command line tools, so if you can't find the command, please install it first.
First, investigate with otool.
$ otool -L LeapPython.so
LeapPython.so:
@loader_path/LeapPython.so (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
@loader_path/libLeap.dylib (compatibility version 0.7.0, current version 1.0.9)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
The part of /Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
is the problematic part.
Rewrite this.
ʻInstall_name_tool [-change old_path new_path]`. In my environment it looks like this: Please change the new_path part appropriately according to each person's environment.
$ install_name_tool -change /Library/Frameworks/Python.framework/Versions/2.7/Python /usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/Current/lib/libpython2.7.dylib LeapPython.so
It seems that it will work if you do the same with macports and your own build. Another caveat is that the on_frame event doesn't fire when running through tmux.
Recommended Posts