Fix deprecation warning by using importlib when possible