How to run Leap Motion in non-Apple Python

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

How to run Leap Motion in non-Apple Python
Leap Motion in Python 3
How to run Notepad ++ Python
How to develop in Python
How to run python in virtual space (for MacOS)
How to run setUp only once in python unittest
Get Leap Motion data in Python.
[Python] How to do PCA in Python
How to collect images in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to run TensorFlow 1.0 code in 2.0
Try using Leap Motion in Python
How to handle Japanese in Python
[Introduction to Python] How to use class in Python?
How to access environment variables in Python
How to dynamically define variables in Python
How to do R chartr () in Python
[Itertools.permutations] How to put permutations in Python
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
How to check opencv version in python
How to switch python versions in cloud9
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to use regular expressions in Python
How to display Hello world in python
How to use is and == in Python
How to write Ruby to_s in Python
How to run a Maya Python script
How to install OpenCV on Cloud9 and run it in Python
How to use the C library in Python
How to receive command line arguments in Python
[REAPER] How to play with Reascript in Python
How to clear tuples in a list (Python)
How to install Python
How to generate permutations in Python and C ++
How to embed a variable in a python string
How to implement Discord Slash Command in Python
Type Python scripts to run in QGIS Processing
How to use Python Image Library in python3 series
How to create a JSON file in Python
How to run some script regularly in Django
How to install python
How to run CNN in 1 system notation in Tensorflow 2
Summary of how to use MNIST in Python
How to specify TLS version in python requests
How to get the files in the [Python] folder
How to use tkinter with python in pyenv
[Python] How to draw a histogram in Matplotlib
How to output "Ketsumaimo" as standard output in Python
How to handle datetime type in python sqlite3
How to make Python Interpreter changes in Pycharm
How to plot autocorrelation and partial autocorrelation in python
How to remove duplicate elements in Python3 list
How to run GUI programs such as tkinter in Python environment on WSL2
[Python] How to run Jupyter-notebook + pandas + multiprocessing (Pool) [pandas] Memo
How to retrieve the nth largest value in Python