{"id":9820,"library":"humanreadable","title":"humanreadable","description":"humanreadable is a Python library to convert human-readable values for sizes, times, and bit rates into other units. It supports various formats like '1MB', '1 day', or '100Mbps'. The current version is 0.4.1. Releases occur irregularly, often tied to Python version support updates and essential bug fixes.","status":"active","version":"0.4.1","language":"en","source_language":"en","source_url":"https://github.com/thombashi/humanreadable","tags":["unit conversion","human-readable","size","time","bitrate","data conversion"],"install":[{"cmd":"pip install humanreadable","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"Size","correct":"from humanreadable import Size"},{"symbol":"Time","correct":"from humanreadable import Time"},{"symbol":"BitPerSecond","correct":"from humanreadable import BitPerSecond"},{"note":"BitsPerSecond is an alias for BitPerSecond, introduced in v0.3.0.","symbol":"BitsPerSecond","correct":"from humanreadable import BitsPerSecond"}],"quickstart":{"code":"from humanreadable import Size, Time, BitsPerSecond\n\n# Convert human-readable size to bytes, kilobytes, etc.\nsize_mb = Size(\"1.5 MB\")\nprint(f\"1.5 MB is {size_mb.byte} bytes\")\nprint(f\"1.5 MB is {size_mb.kbyte} KB\")\n\n# Convert human-readable time to seconds, minutes, hours, etc.\ntime_day = Time(\"2 days 3 hours\")\nprint(f\"2 days 3 hours is {time_day.hours} hours\")\nprint(f\"2 days 3 hours is {time_day.minutes} minutes\")\n\n# Convert human-readable bit rate to bits per second, kilobits per second, etc.\nrate_gbps = BitsPerSecond(\"10 Gbps\")\nprint(f\"10 Gbps is {rate_gbps.bps} bits/second\")\nprint(f\"10 Gbps is {rate_gbps.giga_bps} Gbps\")\n\n# Perform arithmetic operations (available from v0.3.0+)\nsize_a = Size(\"10 MB\")\nsize_b = Size(\"2048 KB\") # 2MB\ntotal_size = size_a + size_b\nprint(f\"10 MB + 2048 KB = {total_size.mbyte} MB\")","lang":"python","description":"Demonstrates how to import and use the `Size`, `Time`, and `BitsPerSecond` classes to parse human-readable strings and access their converted values, including basic arithmetic operations."},"warnings":[{"fix":"Ensure your Python environment is 3.10 or newer (3.12+ recommended for v0.4.1+). If you must use an older Python version, pin `humanreadable` to a compatible release (e.g., `pip install 'humanreadable<0.4.1'` for Python 3.8/3.9).","message":"Python version support has been dropped for older interpreters. Specifically, v0.4.1 dropped support for Python 3.8/3.9, v0.4.0 dropped 3.6, and v0.2.0 dropped 3.5.","severity":"breaking","affected_versions":"<=0.4.0"},{"fix":"If your code expects `BitPerSecond.bps` to return an integer, update it to handle `float` values. This change was introduced in v0.2.0, so older code might fail if not adapted.","message":"The `BitPerSecond.bps` property type changed from `int` to `float`.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Upgrade to `humanreadable>=0.4.0` to ensure correct behavior of the `Time.to_humanreadable()` method for values exceeding one day.","message":"The `to_humanreadable` method for the `Time` class could fail when the value represented more than one day.","severity":"gotcha","affected_versions":"<0.4.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify installation with `pip list | grep humanreadable`. Ensure class names are capitalized correctly (e.g., `Size` not `size`).","cause":"The class name 'Size', 'Time', 'BitPerSecond', or 'BitsPerSecond' is misspelled, or the library is not correctly installed.","error":"ImportError: cannot import name 'Size' from 'humanreadable'"},{"fix":"Adapt your code to expect and handle `float` values from `BitPerSecond.bps`, or explicitly cast to `int` if necessary (e.g., `int(rate.bps)`).","cause":"This error can occur if code written for `humanreadable<0.2.0` (where `BitPerSecond.bps` was `int`) is run with `humanreadable>=0.2.0` (where `BitPerSecond.bps` is `float`), and the code performs `int`-specific operations.","error":"TypeError: 'int' object is not iterable"},{"fix":"The `to_humanreadable` method for `Time` was added in v0.3.0. Upgrade your `humanreadable` library to version 0.3.0 or higher.","cause":"Attempting to use the `to_humanreadable` method on a `Time` object with a version of the library prior to its introduction.","error":"AttributeError: 'Time' object has no attribute 'to_humanreadable'"}]}