try:
    connection = manager.connect('I2Cx')
except KeyError as e:
    print('I got a KeyError - reason "%s"' % str(e))
except:
    print('I got another exception, but I should re-raise')
Поймать KeyError в Python