Registry / testing / icecream

icecream

JSON →
library2.2.0pypypi✓ verified 24d ago

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.

pip install icecream
INSTALL
IMPORT
SIG · ICECREAM
I
icecream
testingpythonv2.2.0
Install
2.4s avg
Import
481ms
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.482s · 27.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.480s · 28MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ic
from icecream import ic

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.

from icecream import ic def calculate_sum(a, b): result = a + b ic(a, b, result) # Inspect multiple variables return result my_num1 = 5 my_num2 = 10 ic(my_num1, my_num2) # Inspect individual variables final_sum = calculate_sum(my_num1, my_num2) ic(f"The final sum is: {final_sum}") # Inspect expressions and strings class MyClass: def __init__(self, name): self.name = name ic(self.name) obj = MyClass("IceCreamExample") ic.disable() # Disable all ic() output ic("This line will not be printed.") ic.enable() # Re-enable ic() output ic("This line will be printed again.")
ic --version
Debug
Known issues
breakingSupport 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.
fix
Ensure your project uses Python 3.9 or newer to maintain compatibility with recent IceCream versions.
affects: <2.1.9 for Python 3.8, <2.1.4 for Python 2/3.7 and older
gotchaCalling `ic.configureOutput()` without any arguments will raise a `TypeError` as of v2.1.3. This method expects at least one configuration parameter.
fix
Always pass a keyword argument to `configureOutput()`, e.g., `ic.configureOutput(includeContext=True)` or `ic.configureOutput(prefix='DBG| ')`.
affects: >=2.1.3
gotchaFor improved debugging in IDEs like VS Code, configure IceCream to output absolute file paths, making them clickable links. By default, `contextAbsPath` is `False`.
fix
Use `ic.configureOutput(includeContext=True, contextAbsPath=True)` to enable absolute path output.
affects: All versions supporting `configureOutput`
gotchaWhen 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.
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.
affects: <2.1.6
gotchaTo 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.
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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'icecream'
The 'icecream' module is not installed in the Python environment.
fix
Install the module using 'pip install icecream'.
AttributeError: module 'icecream' has no attribute 'ic'
The 'ic' function is not imported from the 'icecream' module.
fix
Import the function with 'from icecream import ic'.
TypeError: ic() missing 1 required positional argument
The 'ic' function was called without any arguments.
fix
Ensure that 'ic()' is called with at least one argument, e.g., 'ic(variable)'.
NameError: name 'ic' is not defined
The 'ic' function from the 'icecream' library has not been explicitly imported into the current Python file or scope. Unlike 'print()', 'ic()' is not a built-in function by default and requires an import statement.
fix
Add 'from icecream import ic' at the top of your Python file where 'ic()' is used.
ImportError: cannot import name 'install' from 'icecream'
This error often occurs when attempting to import the 'install' function from the 'icecream' library, possibly due to an older or incompatible installation, or when following outdated documentation. While 'install()' exists to make 'ic' globally available, direct import of 'ic' is the more common and recommended approach for general use.
fix
For basic usage, use 'from icecream import ic' instead. If project-wide global availability is strictly required, ensure your 'icecream' installation is up-to-date and correctly installed (e.g., via 'pip install icecream'). Then, call 'install()' once at the application's entry point, typically after 'from icecream import install'.
Upgrade
Version history
2.2.0latest on PyPI · released Apr 3, 2026
Audit
Dependencies
executingrequiredUsed to reliably locate `ic()` calls in Python source for contextual output, as described in the official README.
Agent activity
5 hits · last 30 days
node
4
Resources
icecream — pip install icecream · libregistry