ImportError: DLL Load failed while importing LeapPython: The Specified module could not be found

973 Views Asked by At

Some Context: I am currently working on a project to communicate between a PyParrot Mambo drone and the Leap Motion Controller. The issue that I am having is that the Leap Motion Controller Software only works in python 2.7 and the PyParrot Mambo Drone is working in Python 3.9. I was able to find a binding for the Leap Motion Controller Software to work with Python 3.7 .When I try to run the Leap Motion code that works in Python 3.7 in Python 3.9 I get an error.

Here is the binding file used to run The Leap Motion Controller in Python 3.7. I get the following error when I run the Sample.py file from the provided folder in python 3.9:

(py39) C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7>python Sample.py
Traceback (most recent call last):
  File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 565, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1108, in create_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Sample.py", line 9, in <module>
    import Leap, sys, time
  File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 17, in <module>
    LeapPython = swig_import_helper()
  File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 16, in swig_import_helper
    return importlib.import_module('LeapPython')
  File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.

If someone could provide clarifications on what changes were made between python 3.7 to 3.9 that would cause these errors and a possible fix to make the python 3.7 code compatible with python 3.9. If There is a Leap Motion Software binding for newer versions of python 3 that would also be quite helpful.

2

There are 2 best solutions below

0
Ultraleap_Dan On

The binding was generated with SWIG which does not implement the Python Stable API so you will need to rebuild the binding for each Python Version for this to work with Python 3.9.

This guide was written for Python 3.3.0 but should help to guide you on the process to rebuild this for Python 3.9.

0
Stefan On

I found ready-to-use Python 3.9 bindings in this GitHub repo (seanschneeweiss/RoSeMotion). I've tested it in my project and it seems to be working well. There are also bindings for 3.6, 3.7, 3.8.