The InChIKey is available as an option on the InChI format. How would you find this out? Well, "babel -Hinchi" gives all of the options, one of which is option "K" indicating "output InChIKey". Here's how to do a SMILES to InChIKey conversion from Python:
import openbabel as obA future version of Pybel will include the InChIKey format directly.
conv = ob.OBConversion()
mol = ob.OBMol()
inchikey = conv.WriteString(mol)
assert inchikey == "WETWJCDKMRHUPV-UHFFFAOYAQ"
Image credit: Gustty