Blender crashes at module import

Hello everyone!

I’m currently trying to integrate the Leap Motion module (http://www.leapmotion.com) in Blender 2.66 (64 bits on Mac OS X Mountain Lion), in order to use the controller’s input in the game engine.

I know Python 3.3 is used in Blender 2.66, and that’s why I recompiled the Leap motion sdk which was in 2.7. So, now, I have three files : Leap.py, LeapPython.so and leapLib.dylib. Some people already achieved to place these files in the correct place, to import Leap in a script in Blender and to make some stuff. Now, these people are on windows.
They put Leap.py and LeapPython.pyd (win version of the .so file mentioned above) in blender-2.65-linux-glibc211-i686/2.65/python/lib/python3.3, and the dll (win version of the .dylib) next to blender.exe.

I’ve been trying to do the equivalent on mac, by putting Leap.py and LeapPython.so in Blender.app/Contents/MacOS/2.66/python/lib/python3.3. I know that the .dylib is in the right spot because sometimes, the blender python interpreter told me that it couldn’t find it.

When it can, blender simply crashes (with console error Abort trap 6). I have absolutely no idea what to do right now and I’ve completely run out of options in google, so if anyone could help me, that would be the most amazing thing that happened to me in the last three days.

Thanks already for your help!

Did you ever figure this out? I’m having a similar problem, but in Cinema 4D. I’m working with Leap as well. It sees the .py and .so files but can’t find dylib. When I add the dylib and execute the python script it crashes Cinema 4D. It makes me think it’s a Leap thing and not a Blender / Cinema 4D thing.

did you try to delete Blender\Python folder? try this so that Blender will rely on system python which is C:\Python33 and so far this will let Blender read all installed modules on the system Python

He said he was on Mac so there is no C drive to worry about. My testing produces a notation error that says the init is missing in the LeapPython.so file. If there is one, it’s not public to be seen by Blender file loader. Can someone recompile a copy so that all is visible and accessible in Mac Blender? Otherwise we will have to use a Client/Server setup to get frames into Mac Blender, which I have done and is working:

Actually, there should be a LeapPython.py file produced also when the compiling is done. This is the actual file imported into Blender, not the LeapPython.so file.

Actually, there is a third way. You can save the information in a file and then read it from the BGE in your script. You have to modify the Leap data displayer script by adding a save method. It’ll be somewhat slower, but usable for some slower activities. And you need only save the parts you need, not the whole frame.

Here’s my write code:

        # Get the palm position
        palm = hand.palm_position
        #a,b,c = tuple(hand.palm_position)
        d2 = { 'palm_position': str('%s' % (palm)) }            
        data.update(d2)
        #print("85 - Palm position updated")
        # Get the palm normal vector  and direction
        normal = hand.palm_normal
        direction = hand.direction
        # Calculate the hand's pitch, roll, and yaw angles
            
        d2 = { 'palmnormal': str('%s' % (normal)),'dirpitch': float('%f' % (direction.pitch * Leap.RAD_TO_DEG)),
           'normroll': float('%f' % (direction.roll * Leap.RAD_TO_DEG)),
           'diryaw': float('%f' % (direction.yaw * Leap.RAD_TO_DEG)) }
        data.update(d2)
        #print("97 - dirpitch, norm roll, diryaw updated")
        
        d2 = {'sphere_radius': float('%f' % (hand.sphere_radius)) }
        data.update(d2)
        #print("101 - sphere_radius updated")
        
        UDP_client(data)  ### Send this frame data
        
        filepath = "/Users/paulcoones/palm_position.txt"
        write_palm_position(,self palm,filepath)
        print("119 - palm_position saved on desktop as palm_position.txt")
        data = None   ### get ready for next frame data 

def write_palm_position(self, palm, filepath):
palm_position = self.palm
f=open(filepath,‘w’,encoding=‘utf-8’)
f.write(palm_position)
f.close()
return

Here’s my read method:

def read_some_data(context, filepath, use_some_setting):
print(“running read_some_data…”)
f = open(filepath, ‘r’, encoding=‘utf-8’)
data = f.read()
f.close()

# would normally load the data here
print(data)
frame = {
    'palm_position':  (0.0,0.0,0.0)
    }
frame.update(data)
print("16 - palm_position:",frame['palm_position'])   
return {'FINISHED'}