helper.packages

Detect whether packages are installed and install them during run-time as needed.

Detect packages


source

check_package_installed

 check_package_installed (package_name:str)
# Check for fastai and fastcore
check_package_installed('fastai')
check_package_installed('fastcore')
True

source

check_package_version_with_version_attribute

 check_package_version_with_version_attribute (package_name:str)

*Checks and returns the version of the specified package if available.

Args: package_name (str): The name of the package to check.

Returns: str or None: The version of the package or None if the package is not available.*

# Example usage
package_name = 'fastai'  # Replace with any package name you want to check
version = check_package_version_with_version_attribute(package_name)
if version:
    print(f"{package_name} version: {version}")
else:
    print(f"{package_name} is not installed or does not have a version attribute.")
fastai version: 2.7.18

Install package during runtime


source

ensure_package_installed

 ensure_package_installed (package_name:str)

Check if a package is installed and install it if not.


source

install_package

 install_package (package_name:str)

Install a package using pip.