MCPcopy Create free account
hub / github.com/modelscope/ms-agent / is_package_installed

Function is_package_installed

ms_agent/utils/utils.py:620–630  ·  view source on GitHub ↗

Checks if a package is installed by attempting to import it. Args: package_or_import_name: The name of the package or import as a string. Returns: True if the package is installed and can be imported, False otherwise.

(package_or_import_name: str)

Source from the content-addressed store, hash-verified

618
619
620def is_package_installed(package_or_import_name: str) -> bool:
621 """
622 Checks if a package is installed by attempting to import it.
623
624 Args:
625 package_or_import_name: The name of the package or import as a string.
626
627 Returns:
628 True if the package is installed and can be imported, False otherwise.
629 """
630 return importlib.util.find_spec(package_or_import_name) is not None
631
632
633def install_package(package_name: str,

Callers 4

__init__Method · 0.90
__init__Method · 0.90
_install_playwrightFunction · 0.90
install_packageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected