Skip to content

pythonjsonlogger.utils 🔗

Utilities for Python JSON Logger

package_is_available 🔗

package_is_available(
    name: str,
    *,
    throw_error: bool = False,
    extras_name: str | None = None
) -> bool

Determine if the given package is available for import.

PARAMETER DESCRIPTION
name

Import name of the package to check.

TYPE: str

throw_error

Throw an error if the package is unavailable.

TYPE: bool DEFAULT: False

extras_name

Extra dependency name to use in throw_error's message.

TYPE: str | None DEFAULT: None

RAISES DESCRIPTION
MissingPackageError

When throw_error is True and the return value would be False

RETURNS DESCRIPTION
bool

If the package is available for import.