list_packages¶
Available Functions¶
list_packages.main¶
- list_packages.main.list_installed_packages(format='list')¶
Retrieve a list of installed Python packages.
- Parameters:
format (str) – Output format. Defaults to ‘list’. Accepts ‘list’ or ‘json’.
- Returns:
List of dictionaries containing package information. If format=’json’, a JSON string is returned.
- Return type:
list or str
- Each dictionary contains the following keys:
‘package’ (str): Package name.
‘version’ (str): Package version.
‘depends’ (list): List of dictionaries containing package information.
Example
[{‘package’: ‘Jinja2’, ‘version’: ‘3.1.2’, ‘depends’: [{‘package’: ‘markupsafe’, ‘version’: ‘>=2.0’}]}]
If format=’json’, the function returns a JSON-formatted string representing the list of installed packages.