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)
| 618 | |
| 619 | |
| 620 | def 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 | |
| 633 | def install_package(package_name: str, |
no outgoing calls
no test coverage detected