This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: utils.module_paths

Utility functions for finding modules

Utility functions for finding modules on sys.path.

find_mod finds named module on sys.path.

get_init helper function that finds __init__ file in a directory.

find_module variant of imp.find_module in std_lib that only returns path to module and not an open file object as well.

3 Functions

IPython.utils.module_paths.find_module(name, path=None)

imp.find_module variant that only return path of module.

The imp.find_module returns a filehandle that we are not interested in. Also we ignore any bytecode files that imp.find_module finds.


name : str

name of module to locate

path : list of str

list of paths to search for name. If path=None then search sys.path


filename : str

Return full path of module or None if module is missing or does not have .py or .pyw extension


Get __init__ file path for module directory


dirname : str

Find the __init__ file in directory dirname


init_path : str

Path to __init__ file


Find module module_name on sys.path

Return the path to module module_name. If module_name refers to a module directory then return path to __init__ file. Return full path of module or None if module is missing or does not have .py or .pyw extension. We are not interested in running bytecode.


module_name : str


modulepath : str

Path to module module_name.