Fix PIL import
Don't use replica set client when there is no replica.