ImportError: no module named Leap

I started working on Leap Motion Controller, and trying to execute my code, I get this error:

ImportError: No module named Leap

I added the path to the required libraries

import sys 
sys.path.append("usr/lib/Leap:/path/to/lib/x86:/path/to/lib")
import thread, time
from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture

What am I doing wrong?

I am working on a Linux platform: Ubuntu 13.10, 32-bit

+4
source share
2 answers

You cannot add a colon separated list of paths like this, since Python sys.pathsaves the path entries as a list, not a colon separated list. Each folder must be added separately. Also, usr/lib/Leapit seems like a slash is missing.

Something like this should work:

sys.path.append("/usr/lib/Leap")
sys.path.append("/path/to/lib/x86")
sys.path.append("/path/to/lib")

Or that:

sys.path += ["/usr/lib/Leap", "/path/to/lib/x86", "/path/to/lib"]
+3
source

sys.path , . , , :

sys.path.append("/usr/lib/Leap")
sys.path.append("/path/to/lib/x86")
sys.path.append("/path/to/lib")

extend , - , , , split :

sys.path += "/usr/lib/Leap:/path/to/lib/x86:/path/to/lib".split( ":" )

, , . :

for p in "/usr/lib/Leap:/path/to/lib/x86:/path/to/lib".split( ":" ):
     if p not in sys.path: sys.path.append( p )
0

All Articles