flopy.utils.utl_import module

get_version(module: module) str[source]
import_optional_dependency(name: str, error_message: str = '', errors: str = 'raise', min_version: str | None = None)[source]

Import an optional dependency.

By default, if a dependency is missing an ImportError with a nice message will be raised. If a dependency is present, but too old, we raise.

Parameters:
  • name (str) – The module name.

  • error_message (str) – Additional text to include in the ImportError message.

  • errors (str {'raise', 'warn', 'ignore'}) –

    What to do when a dependency is not found or its version is too old.

    • raise : Raise an ImportError

    • warn : Only applicable when a module’s version is to old. Warns that the version is too old and returns None

    • ignore: If the module is not installed, return None, otherwise, return the module, even if the version is too old. It’s expected that users validate the version locally when using errors="ignore" (see. io/html.py)

    • silent: Same as “ignore” except warning message is not written to the screen.

  • min_version (str, default None) – Specify a minimum version that is different from the global FloPy minimum version required.

Returns:

maybe_module – The imported module, when found and the version is correct. None is returned when the package is not found and errors is False, or when the package’s version is too old and errors is 'warn'.

Return type:

Optional[ModuleType]