#!/usr/local/bin/python3 from importlib.util import spec_from_file_location, module_from_spec from importlib import find_loader l = find_loader('os') spec = spec_from_file_location('os', loader=l) module = module_from_spec(spec)