importbypath(path, name=None)[source]#

Import a module by path.

Useful for importing multiple versions of the same module for comparison purposes.

  • path (str/path) – the path to load the module from (with or without

  • name (str) – the name of the loaded module (by default, the file or folder name from the path)


# Load a module that isn't importable otherwise
mymod = sc.importbypath('my file with')

# Load two versions of the same folder
old = sc.importbypath('/path/to/old/lib', name='oldlib')
new = sc.importbypath('/path/to/new/lib', name='newlib')

See also sc.importbyname().

New in version 3.0.0.