If PyQuery isn't available, it just doesn't set self.q and later, when it is accessed in __call__, it throws an exception. The solution is to set it to None if PyQuery isn't available.