msticpy.init.nbinit module

Initialization for Jupyter Notebooks.

msticpy.init.nbinit.init_notebook(namespace: Optional[Dict[str, Any]] = None, def_imports: str = 'all', additional_packages: Optional[List[str]] = None, extra_imports: Optional[List[str]] = None, **kwargs)

Initialize the notebook environment.

Parameters
  • namespace (Dict[str, Any], optional) – Namespace (usually globals()) into which imports are to be populated. By default, it will use the ipython user_global_ns.

  • def_imports (str, optional) – Import default packages. By default “all”. Possible values are: - “all” - import all packages - “nb” - import common notebook packages - “msticpy” - import msticpy packages - “none” (or any other value) don’t load any default packages.

  • additional_packages (List[str], optional) – Additional packages to be pip installed, by default None. Packages are specified by name only or version specification (e.g. “pandas>=0.25”)

  • user_install (bool, optional) – Install packages in the “user” rather than system site-packages. Use this option if you cannot or do not want to update the system packages. You should usually avoid using this option with standard Conda environments.

  • extra_imports (List[str], optional) – Additional import definitions, by default None. Imports are specified as up to 3 comma-delimited values in a string: “{source_pkg}, [{import_tgt}], [{alias}]” source_pkg is mandatory - equivalent to a simple “import xyz” statement. {import_tgt} specifies an object to import from the package equivalent to “from source_pkg import import_tgt” alias allows renaming of the imported object - equivalent to the “as alias” part of the import statement. If you want to provide just source_pkg and alias include an additional placeholder comma: e.g. “pandas, , pd”

  • friendly_exceptions (Optional[bool]) – Setting this to True causes msticpy to hook the notebook exception handler. Any exceptions derived from MsticpyUserException are displayed but do not produce a stack trace, etc. Defaults to system/user settings if no value is supplied.

  • verbose (Union[int, bool], optional) – Controls amount if status output, by default 1 0 = No output 1 or False = Brief output (default) 2 or True = Detailed output

  • config (Optional[str]) – Use this path to load a msticpyconfig.yaml. Defaults are MSTICPYCONFIG env variable, home folder (~/.msticpy), current working directory.

  • no_config_check (bool, optional) – Skip the check for valid configuration. Default is False.

  • verbosity (int, optional) –

Raises

MsticpyException – If extra_imports data format is incorrect. If package with required version check has no version information.

msticpy.init.nbinit.list_default_imports()

List the default imports for init_notebook.