It wouldn't be very PEP-8'y, but you could move these imports to be inside the migrate() function, and only attempt them if the user is using Qpid. It's fine if you prefer to keep it this way since it does work.