Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running sample project #3

Open
The-Real-Thisas opened this issue Dec 23, 2023 · 12 comments
Open

Error running sample project #3

The-Real-Thisas opened this issue Dec 23, 2023 · 12 comments

Comments

@The-Real-Thisas
Copy link

Traceback (most recent call last):
  File "/Users/thisas/Desktop/leapc-python-bindings/leapc-python-api/src/leap/__init__.py", line 74, in <module>
    from leapc_cffi import ffi, libleapc
  File "/Applications/Ultraleap Hand Tracking.app/Contents/LeapSDK/leapc_cffi/__init__.py", line 1, in <module>
    from ._leapc_cffi import ffi, lib as libleapc
ModuleNotFoundError: No module named 'leapc_cffi._leapc_cffi'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/thisas/Desktop/leapc-python-bindings/examples/tracking_event_example.py", line 7, in <module>
    import leap
  File "/Users/thisas/Desktop/leapc-python-bindings/leapc-python-api/src/leap/__init__.py", line 80, in <module>
    raise ImportError(
ImportError: Cannot import leapc_cffi: Unknown error, please consult readme for help. Attempting to find leapc_cffi within /Applications/Ultraleap Hand Tracking.app/Contents/LeapSDK. Caught ImportError: No module named 'leapc_cffi._leapc_cffi'
@jeffp123
Copy link

same

@EthoIRL
Copy link

EthoIRL commented Dec 26, 2023

Renaming ~\Ultraleap\LeapSDK\leapc_cffi\_leapc_cffi.cp38-win_amd64.pyd or whatever .pyd/.so is present to _leapc_cffi.pyd/_leapc_cffi.so seemed to fix the issue for me.

@The-Real-Thisas
Copy link
Author

@EthoIRL I've tried that,
Screenshot 2023-12-26 at 3 16 10 pm
But it still seems to give the same error

(base)  ~/Desktop/leapc-python-bindings/ [main] python3 examples/visualiser.py
Traceback (most recent call last):
  File "/Users/thisas/Desktop/leapc-python-bindings/leapc-python-api/src/leap/__init__.py", line 74, in <module>
    from leapc_cffi import ffi, libleapc
  File "/Applications/Ultraleap Hand Tracking.app/Contents/LeapSDK/leapc_cffi/__init__.py", line 1, in <module>
    from ._leapc_cffi import ffi, lib as libleapc
ModuleNotFoundError: No module named 'leapc_cffi._leapc_cffi'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/thisas/Desktop/leapc-python-bindings/examples/visualiser.py", line 1, in <module>
    import leap
  File "/Users/thisas/Desktop/leapc-python-bindings/leapc-python-api/src/leap/__init__.py", line 80, in <module>
    raise ImportError(
ImportError: Cannot import leapc_cffi: Unknown error, please consult readme for help. Attempting to find leapc_cffi within /Applications/Ultraleap Hand Tracking.app/Contents/LeapSDK. Caught ImportError: No module named 'leapc_cffi._leapc_cffi'

@EthoIRL
Copy link

EthoIRL commented Dec 26, 2023

@The-Real-Thisas
_leapc_cffi*.pyd is specifically for window's and window's alone. Try renaming _leapc_cffi.cpython-38-darwin.so to _leapc_cffi.so. I've only tested this on a window's machine so your mileage may vary.

https://github.com/ultraleap/leapc-python-bindings/blob/2341c6c3db5dc08236bb52890d8c43a224139694/leapc-python-api/src/leap/__init__.py#L24C1-L29C2

@rodolpheh
Copy link

Have you tried rebuilding the module?
https://github.com/ultraleap/leapc-python-bindings#missing-compiled-module

@jeffp123
Copy link

Also on MacOS. I tried renaming that _leapc_cffi.cpython-38-darwin.so to _leapc_cffi.so and re-ran:

python -m build leapc-cffi
pip install leapc-cffi/dist/leapc_cffi-0.0.1.tar.gz
pip install -e leapc-python-api
python examples/tracking_event_example.py

and still getting:

ImportError: Cannot import leapc_cffi: Unknown error, please consult readme for help. Attempting to find leapc_cffi within /Applications/Ultraleap Hand Tracking.app/Contents/LeapSDK. Caught ImportError: dlopen(/Users/chaim/miniconda3/lib/python3.9/site-packages/leapc_cffi/_leapc_cffi.abi3.so, 0x0002): symbol not found in flat namespace '_LeapCameraMatrix'

when I try the example.


I remember a few years ago, there was a Javascript API and all that was necessary was to plug in the Leap Motion device and you could start getting signal from it to do cool things in a web browser. I actually wanted to make a demo to show "how easy it is" to get started with the Leap Motion for an upcoming presentation, but with the latest updates it looks like you are out of luck unless you are using Unity or Unreal Engine.

This Python API seemed promising, but that it cannot even run the example in the README is disappointing.


I still have yet to try this on a Raspberry Pi 4. (I tried it on a RP3 and it did not work, but that seems correct according to the system requirements.) Still though, the barriers to entry with the Leap Motion seem to have been raised in the past few years.

@jeffp123
Copy link

Oh, re-reading, I just noticed the error message above is not the same as what I am getting:

symbol not found in flat namespace '_LeapCameraMatrix'

If it would help, I could make a new issue for this...

@The-Real-Thisas
Copy link
Author

It seems to work @EthoIRL after renaming to _leapc_cffi.so , trying to find the root of this bug it seems to be in https://github.com/ultraleap/leapc-python-bindings/blob/main/leapc-cffi/setup.py because in https://github.com/ultraleap/leapc-python-bindings/blob/main/leapc-python-api/src/leap/__init__.py#L24 the check passes however. Here https://github.com/ultraleap/leapc-python-bindings/blob/main/leapc-cffi/setup.py#L36 it's static. Whats weird is that on Darwin (mac) it's looking for 'libLeapC.5.dylib' which does indeed exist so I don't know what the libLeapC.so has to do with it, it's possible since I'm on m1 it's trying to compile rather for Linux-Arm ?

@The-Real-Thisas
Copy link
Author

I'm going to see if I can make a fix by using fnmatch to find the file using the same patterns as the https://github.com/ultraleap/leapc-python-bindings/blob/main/leapc-python-api/src/leap/__init__.py#L24

@RodolpheHoudas-UL
Copy link

@chaimpeck This error happens if you installed the wrong version of the hand tracking on your Mac. There are two versions depending on your architecture: M1 & M2 (for ARM64), and Intel (for x64). Make sure you use the right one for your Mac.

@The-Real-Thisas If Python cannot find the library it could be because you're using a different version of the Python interpreter than the one that was used to build the CFFI module (CPython 3.8 at the time of writing this). In that case, you need to rebuild the module: https://github.com/ultraleap/leapc-python-bindings#missing-compiled-module

I've been testing this on a Mac M2 today and it works. No need to rename anything, just following the instructions should work.

@ericelbing
Copy link

@chaimpeck This error happens if you installed the wrong version of the hand tracking on your Mac. There are two versions depending on your architecture: M1 & M2 (for ARM64), and Intel (for x64). Make sure you use the right one for your Mac.

I have the right version installed and got the same error, tried it today on a M1 Mac, with Python 3.8 (even got the error after rebuilding the CFFI module).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants