About Setting a Break Point


Author: Patrick Li

I try the code under Jupyter notebook to set a break point. It seems that the command: import ipdb; ipdb.set_trace() does not work in the notebook. From online sources, I find out one possibility to set the break point as the follows?

%%file plot_temp.py
import numpy as np
import matplotlib.pyplot as plt

def plot_log():
    # import ipdb; ipdb.set_trace()
    from IPython.core.debugger import Tracer
    fig, ax = plt.subplots()
    x = np.logspace(1,2,10)
    ax.plot(x, np.log(x))


Hi Patrick,

Thanks for letting us know and giving a proposed solution.

For me, “import ipdb; ipdb.set_trace()” works fine in the notebook.

Did you install ipdb separately? It doesn’t come with Anaconda. To install it type “pip install ipdb” in a terminal. (A terminal is called cmd under Windows.)

But your solution worked fine for me too.

Regards, John.


Author: Patrick Li

Hi John,

Many thanks for your double-checking. I tried in the cmd under Windows with “pip install ipdb” as well as “pip install --upgrade ipdb”. These commands work fine, and I have the most updated ipdb, but it does not help solving this problem in Jupyter Notebook. It seems my machine have some other bug, hope it is not related to Windows platform, maybe I should consider using a linux machine…

Anyway, I believe “import ipdb; ipdb.set_trace()” should be the standard way to use the package, and it is guaranteed as it works in your computer system.

Best regards,



HI Patrick,

Thanks for getting back to us. It might be related to the Windows platform.

I highly recommend Linux as a programming environment. It’s not difficult to set up your machine so that you can choose either Windows or Linux at boot time. (I recommend the Ubuntu distribution as a good place to start.)

Good luck with your coding and research.

All the best,



Author: Patrick Li

Hi John,

Thanks for your suggestion on Ubuntu. Speaking about research, I would like to ask for your opinion. I am doing agent-based computational economics, mainly at macroeconomics. What I have been using is Matlab, C++ for coding Monte-Carlo simulation. Now I am switching to Python and Julia. I am not sure if it would be interesting to introduce codes for agent-based computational economics in quant-econ project?



Hi Patrick,

We do have a small amount of agent based computational economics:

I really like that model but never found anything else from the field that I liked as much.

One possibility if you’ve got some useful code is to explain it in a notebook and add it here:

Regards, John.