Python 3.4: How to import a module given the full path? [duplicate]

This should work for all python files, regardless of file extension:

import importlib.machinery

modulename = importlib.machinery.SourceFileLoader('modulename','/Path/To/module.py').load_module()

This method was mentioned in the deprecation message in the imp.load_module documentation.

Leave a Comment