def _check_mp_install()

in utils/nb_check.py [0:0]


def _check_mp_install(min_mp_ver, mp_release, extras, pip_quiet):
    """Check for and try to install required MSTICPy version."""
    # Use the release ver specified in params, in the environment or
    # the notebook default.
    pkg_version = _get_pkg_version(min_mp_ver)
    mp_install_version = mp_release or os.environ.get("MP_TEST_VER", str(pkg_version))
    exact_version = bool(mp_release or os.environ.get("MP_TEST_VER"))

    try:
        check_mp_ver(min_msticpy_ver=mp_install_version)
        if extras:
            # If any extras are specified, always trigger an install
            _disp_html("Running install to ensure extras are installed...<br>")
            _install_mp(
                mp_install_version=mp_install_version,
                exact_version=exact_version,
                extras=extras,
                quiet=pip_quiet,
            )
    except ImportError:
        _install_mp(
            mp_install_version=mp_install_version,
            exact_version=exact_version,
            extras=extras,
            quiet=pip_quiet,
        )
        _disp_html("Installation completed. Attempting to re-import/reload MSTICPy...")
        # pylint: disable=unused-import, import-outside-toplevel
        if "msticpy" in sys.modules:
            try:
                importlib.reload(sys.modules["msticpy"])
            except ImportError:
                _disp_html(RELOAD_MP)
        else:
            import msticpy
        # pylint: enable=unused-import, import-outside-toplevel
        check_mp_ver(min_msticpy_ver=mp_install_version)
    except RuntimeError:
        _disp_html("Installation skipped.")