The `uptime` library provides a cross-platform way to retrieve system uptime and boot time, aiming to do so without relying on external processes like parsing `uptime(1)` command output. It works on various major platforms, including Linux, Windows, macOS, and BSD systems. Despite its current version 3.0.1 being released in 2013, it remains a stable and widely used utility for basic system information.
pip install uptimeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to fetch the system's uptime in seconds and its boot time as a `datetime` object. It includes error handling for cases where uptime or boot time cannot be determined.
Ensure your Python installation's `ctypes` module is functioning correctly. It is advisable to test `uptime` on your specific deployment environment before critical reliance. If `None` is returned, implement checks in your code.
Always check the return type of each function. For calculations involving both, convert `float` uptime to a `datetime.timedelta` object, or the `datetime.datetime` to a timestamp, to prevent `TypeError`.
Install the package using pip: `pip install uptime`.
This indicates a potentially corrupted or non-standard Python installation. Verify the integrity of your Python installation and ensure the `datetime` module is present and importable. Reinstalling Python might be necessary.
No dependency data recorded yet.