SlicerLeapMotionControl in Slicer 4.11.0

Operating system:windows10
Slicer version:4.11.0
Expected behavior: **SlicerLeapMotionControl**can work
Actual behavior:SlicerLeapMotionControl cannot work

I add the src directory to the additional module paths,but there are some errors in python.
What can I do to make the SlicerLeapMotionControl work in Slicer4.11? It can work in Slicer4.8.

Thanks for reporting the problem.

Since Slicer was recently updated to use with Python 3 (see [1] for more details), extensions and more general any example of code also need to be updated to support python 3 and it seems the SlicerLeapMotionControl scripts still need to be updated to support it.

[1] Updating slicer to work with python 3

For reference, migration guide explaining how to update code to work with Python 3 is available at

I will update the code following the migration guide, it would be great if you could test the changes once this is done.

Here is a PR that should fix the issue reported in your initial screenshot:

That said, there are most likely other problem to address. Could you try the updated code available in the Pull request linked above and report the other errors ?

Wow,it’s a pleasure to do the test work.:joy:
Is it after midnight in America or Canada? :rofl: You replied so soon at this time.
I will try your suggestions in the future hours.

Em,I switch to the code you just push but there are still errors.

Probably you need to download the LeapMotion Python SDK, and replace SDK files in the extension’s folder with their Python3 version.

It also looks like you are still using the old version of the file. Line is expected to be different.

I modify the according to your code.It now has different errors.

The next step would be to obtain the leap motion SDK for python 3.x.

Reading, it seems they have been removed from the latest SDK (Leap Motion Orion 4.0.0):

Removed Leap.dll, all associated language bindings (LeapPython, LeapJava, Objective-C) and samples Leap Motion Orion 4.0.0

Now, reading the “Setting up a project” section found in the v3.2 of the documentation, we can find information about the python bindings:

The LeapPython library included in the Leap Motion SDK supports only Python 2.7. However, the SDK also includes the SWIG interface file used to generate the LeapPython source code, so advanced users can generate and compile their own version of LeapPython. For instructions, refer to Generating a Python 3.3.0 Wrapper with SWIG 2.0.9 in our support knowledge base.

If you download the v3.2 of the SDK and try to follow instruction from , you should be able to address the remaining issues.

Also look like there are readily available code to make the python 3 binding for linux … see but i couldn’t find a similar project.

Note that it may exist, i just didn’t spend too much time searching …

I compile and generate LeapPython.dll(x86) file successfully by following this
But there are still errors.
And when I build LeapPython.dll(x64) with Leap.lib(x64),link error occur.

You can probably fix the link errors by using the 64-bit LeapMotion library files.

Hi ,@jcfr @lassoan i did the same thing that @JaceYang did , i build LeapPython.dll with Leap.lib(x64), it can successfully generate LeapPython.dll, so i change it to leapPython.pyd and put it into the demo1 folder to replace the old one,and then add it to 3D Slicer, but those errors have not changed comparing to the unmodified source code( original source code) and they are the same errors that Jace Yang has got.

Hi,everyone @jcfr @lassoan@JaceYang. I recently found that there is no way for me to develop a leap motion python Module on slicer 4.11.0(python 3.6.7) with leap motion V3.2(only support Python2.7). I tried Generating a Python 3.3.0 Wrapper with SWIG 2.0.9, but errors remains. and then i try to Generating a Python 3.6.7 Wrapper with SWIG 2.0.9, it failed at the beginning to produce a LeapPython.dll. So i would like to know if you guys can give me some advice? If there is no solution for this issue, i may change to develop a c++ module. Thanks in advance.

Hi, Mikecsu, Did you deal with this problem now? I donnot know can I perform the leap motion in the last version slicer now?

Traceback (most recent call last):
  File "C:/slicerpy/leapmotion/", line 20, in __init__
    logic = SlicerLeapModuleLogic()
  File "C:/slicerpy/leapmotion/", line 164, in __init__
    self.LeapController = Leap.Controller()
AttributeError: module 'Leap' has no attribute 'Controller'

I don’t think there is a mistake:
`class SlicerLeapModuleLogic(object):

      def __init__(self):
        import Leap
        self.LeapController = Leap.Controller()
        self.enableAutoCreateTransforms = False    

the ‘’ file contain the class:Controller() , but the slicer(4.11) cannot import it, any problem?

Hello everyone,

Do we actually have a functionality of leap motion on slicer?