{"id":2539,"library":"icecream","title":"IceCream","description":"Never use print() to debug again: inspect variables, expressions, and program execution with a single, simple function call. IceCream is a Python library that makes debugging effortless and more readable. It's currently at version 2.2.0 and has an active release cadence with frequent minor updates.","status":"active","version":"2.2.0","language":"en","source_language":"en","source_url":"https://github.com/gruns/icecream","tags":["debugging","developer-tools","productivity","print-debugging"],"install":[{"cmd":"pip install icecream","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used to reliably locate `ic()` calls in Python source for contextual output, as described in the official README.","package":"executing","optional":false}],"imports":[{"symbol":"ic","correct":"from icecream import ic"}],"quickstart":{"code":"from icecream import ic\n\ndef calculate_sum(a, b):\n    result = a + b\n    ic(a, b, result) # Inspect multiple variables\n    return result\n\nmy_num1 = 5\nmy_num2 = 10\nic(my_num1, my_num2) # Inspect individual variables\nfinal_sum = calculate_sum(my_num1, my_num2)\nic(f\"The final sum is: {final_sum}\") # Inspect expressions and strings\n\nclass MyClass:\n    def __init__(self, name):\n        self.name = name\n        ic(self.name)\n\nobj = MyClass(\"IceCreamExample\")\n\nic.disable() # Disable all ic() output\nic(\"This line will not be printed.\")\nic.enable() # Re-enable ic() output\nic(\"This line will be printed again.\")","lang":"python","description":"Import `ic` and use it to wrap variables or expressions for detailed output, including variable names, values, and context. Call `ic()` without arguments to log filename, line number, and function name. `ic.disable()` and `ic.enable()` can control output globally."},"warnings":[{"fix":"Ensure your project uses Python 3.9 or newer to maintain compatibility with recent IceCream versions.","message":"Support for Python 3.8 was officially removed in IceCream v2.1.9. Prior to this, support for all Python versions before 3.8 (including Python 2) was dropped in v2.1.4.","severity":"breaking","affected_versions":"<2.1.9 for Python 3.8, <2.1.4 for Python 2/3.7 and older"},{"fix":"Always pass a keyword argument to `configureOutput()`, e.g., `ic.configureOutput(includeContext=True)` or `ic.configureOutput(prefix='DBG| ')`.","message":"Calling `ic.configureOutput()` without any arguments will raise a `TypeError` as of v2.1.3. This method expects at least one configuration parameter.","severity":"gotcha","affected_versions":">=2.1.3"},{"fix":"Use `ic.configureOutput(includeContext=True, contextAbsPath=True)` to enable absolute path output.","message":"For improved debugging in IDEs like VS Code, configure IceCream to output absolute file paths, making them clickable links. By default, `contextAbsPath` is `False`.","severity":"gotcha","affected_versions":"All versions supporting `configureOutput`"},{"fix":"Upgrade to IceCream v2.1.6 or newer to benefit from improved pretty-printing that gracefully handles unorderable keys. If upgrading is not possible, custom `argToStringFunction` may be needed.","message":"When dealing with complex objects like SymPy objects, earlier versions (before v2.1.6) could encounter `TypeError` during pretty-printing if dictionary keys were unorderable. This was fixed by implementing a fallback.","severity":"gotcha","affected_versions":"<2.1.6"},{"fix":"Call `ic.disable()` at the entry point of your application or conditionally based on an environment variable (`if os.environ.get('DEBUG') == 'false': ic.disable()`). Remember to `ic.enable()` if you want output again.","message":"To avoid leaving debugging output in production, IceCream provides `ic.disable()` to globally silence all `ic()` calls without removing them from your code. This is a common and recommended practice.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}