The proper import statement for the above is import importlib.util. Is what exact Python version did the buggy code work?
import importlib.util