Skip to main content

find_package

Find the prefix that a package is installed under, and the path that it would be imported from.

def find_package(
import_name: str
) - > tuple[str | None, str]

Find the prefix that a package is installed under, and the path that it would be imported from. The prefix is the directory containing the standard directory hierarchy (lib, bin, etc.). If the package is not installed to the system (sys.prefix) or a virtualenv (site-packages), None is returned. The path is the entry in sys.path that contains the package for import. If the package is not installed, it's assumed that the package was imported from the current working directory.

Parameters

NameTypeDescription
import_namestrThe name of the package to find, as it would be used in an import statement.

Returns

TypeDescription
`tuple[strNone, str]`