Last modified: Jun 11, 2026

How to Install IceCream Debugger

Debugging is a key part of coding. IceCream makes it easy. This tool prints variables, expressions, and function calls for you. It saves time and reduces errors.

In this article, you will learn how to install IceCream debugger in Python. We will cover setup, basic usage, and examples. The guide is simple and clean.

What Is IceCream Debugger?

IceCream is a Python library. It helps you inspect code quickly. Instead of writing print() statements, you use ic(). It shows the file name, line number, and value.

It is great for beginners and experts. It makes debugging faster and more readable. You can use it for small scripts or large projects.

Prerequisites

Before installing, ensure you have Python installed. IceCream works with Python 3.6 or newer. Check your Python version with this command:


python --version

If Python is not installed, download it from python.org. You also need pip. Pip is the package installer for Python. Most Python versions include pip.

How to Install IceCream Debugger

Installing IceCream is simple. Use pip in your terminal. Run this command:


pip install icecream

If you use Python 3 on some systems, you may need pip3. Try this:


pip3 install icecream

After installation, verify it works. Open a Python shell and import IceCream:


from icecream import ic
print("IceCream is installed!")

No errors mean success. You are ready to debug.

Basic Usage Examples

Let's test IceCream with simple code. The ic() function prints the variable name and its value. Here is an example:


from icecream import ic

# Debug a variable
name = "Alice"
ic(name)

# Debug an expression
x = 10
y = 20
ic(x * y)

# Debug a function call
def greet(person):
    return f"Hello, {person}!"

ic(greet("Bob"))

Output will look like this:


ic| name: 'Alice'
ic| x * y: 200
ic| greet("Bob"): 'Hello, Bob!'

Notice the format. It shows the file name and line number in real projects. This helps you find where the debug output comes from.

Using IceCream in Larger Projects

IceCream works well in scripts and applications. You can add it anywhere. For example, in a loop:


from icecream import ic

numbers = [1, 2, 3, 4, 5]
for num in numbers:
    ic(num * 2)  # See each doubled value

Output:


ic| num * 2: 2
ic| num * 2: 4
ic| num * 2: 6
ic| num * 2: 8
ic| num * 2: 10

You can also debug multiple items at once. Use ic() with several arguments:


from icecream import ic

a = 5
b = 10
ic(a, b, a + b)

Output:


ic| a: 5, b: 10, a + b: 15

This is much cleaner than multiple print() statements.

Disabling IceCream Output

Sometimes you want to turn off debugging. IceCream makes it easy. Use ic.disable() to stop output. Use ic.enable() to turn it back on.


from icecream import ic

ic("This prints")
ic.disable()
ic("This does not print")
ic.enable()
ic("This prints again")

Output:


ic| 'This prints'
ic| 'This prints again'

This is useful for production code. You can keep debug statements but disable them easily.

Customizing IceCream Output

You can change how IceCream formats output. Use ic.configureOutput(). For example, add a prefix or change the style.


from icecream import ic

# Add a custom prefix
ic.configureOutput(prefix='DEBUG: ')
ic("Custom prefix works")

Output:


DEBUG: 'Custom prefix works'

You can also hide the file and line number. This keeps output clean for simple scripts.

Common Issues and Fixes

Some users face errors during installation. If pip fails, upgrade pip first:


pip install --upgrade pip

Then retry installing IceCream. If you get a permission error on Linux or macOS, use:


pip install --user icecream

On Windows, run the terminal as administrator. This solves most permission problems.

If you use a virtual environment, activate it first. Then install IceCream inside it. This keeps your project dependencies separate.

Best Practices for IceCream

Use IceCream only during development. Remove or disable it before deploying code. It is not meant for production logs.

Keep debug statements focused. Do not add too many at once. This makes output hard to read.

Combine IceCream with other tools. For example, use it with unit tests to check values. It also works well with Jupyter notebooks.

Remember to use clear variable names. This helps IceCream output make sense. Avoid single-letter names in debug code.

Conclusion

Installing IceCream debugger in Python is fast and easy. Use pip to install it. Then import ic and start debugging. It prints variable names, values, and line numbers automatically.

IceCream saves you from writing many print() statements. It makes your code cleaner and debugging faster. Use it in loops, functions, and complex expressions. Disable it when you are done.

Now you know how to install and use IceCream. Try it in your next Python project. It will improve your workflow and help you find bugs quickly.