Note: I originally installed this in order to talk to the Pololu Micro Maestro Servo Controller, however it was far too complicated to do what I wanted. See this post: Raspberry Pi and the Pololu Servo Controller

This page is very obsolete. You can find PyUSB at http://sourceforge.net/projects/pyusb/

It took me an unusual amount of Googling to find what I needed to get the PyUSB module to install and work with the RPi, so I thought I would post the steps here. As usual, nothing difficult, just knowing what needed to be done.

First, I found a post that indicated that the RPi already had libusb installed, all you had to do was create a symbolic link to it. I’m not actually sure you need to do this, but I did as I was poking about and now it all works so I’ll include it.

sudo ln -s /usr/lib/arm-linux-gnueabihf/libusb-1.0.a /usr/local/lib/libusb-1.0.a

After that, some more searching got me to a link for an RPi Magazine of sorts, a PDF file here:
The Mag Pi.pdf

Which had this info in it:

Downloading & Compiling Python PyUSB libraries

To be able to control your USB device you will need the Python USB Libraries. The PyUSB Libraries have been written in collaboration by a team of ‘opensource’ volunteers. To download them, open midori web browser and visit:

http://goo.gl/N9L4e

This will give you the option to save the pyusb1.0.0a1.tar.gz

Then expand the compressed tarball file:
tar xvf pyusb-1.0.0-a1.tar.gz

List the files and directories by typing ‘ls’
(You should see a new directory called “pyusb1.0.0a1”)
Change directory by typing:
cd pyusb-1.0.0-a1

To install it, type
sudo python setup.py install

Sample code

This code is meant for a robot arm I don’t have so this is just for reference, some more info is available on the pyUSB site:
http://pyusb.sourceforge.net/docs/1.0/tutorial.html

# ROBOT ARM CONTROL PROGRAM
# import the USB and Time libraries into Python
import usb.core, usb.util, time

# Allocate the name 'RoboArm' to the USB device
RoboArm = usb.core.find(idVendor=0x1267, idProduct=0x0000)

# Check if the arm is detected and warn if not
if RoboArm is None:
   raise ValueError("Arm not found")

# Create a variable for duration
Duration=1

# Define a procedure to execute each movement
def MoveArm(Duration, ArmCmd):
    # Start the movement
    RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    # Stop the movement after waiting specified duration
    time.sleep(Duration)
    ArmCmd=[0,0,0]
    RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)

# Give the arm some commands
MoveArm(1,[0,1,0]) # Rotate Base Anticlockwise
MoveArm(1,[0,2,0]) # Rotate Base Clockwise
MoveArm(1,[64,0,0]) # Shoulder Up

To try out this code type into the command line:
sudo python arm.py

(sudo is required as USB requires root access)