[IPython-dev] Reloading compiled modules in a notebook

Austin Bingham austin.bingham at gmail.com
Wed Mar 19 06:01:57 EDT 2014

(I apologize if this gets doubly-posted. I sent this earlier but it
never seemed to show up on the list.)

I've been scratching my head over this for a while now. I've created a
"magic" command which compiles Boost.Python C++ into importable
extension modules. In a notebook, I use that magic in one cell to
compile the module, and in the next cell (a normal Python cell) I
import that module. By and large this seems to work just fine.

However, if I change the code in the C++ cell and rebuild the
extension module, I can't find a way to convince the Python cell to
reimport the module. I've tried autoreload, aimport, reload, dreload,
and everything else I can think of, but ipython just doesn't seem to
want to reload/reimport the module.

I've verified that the module is being correctly rebuilt at the right
times. That is, I'm able to change the C++ code in the notebook, rerun
the cell, and then import the generated module in a separate Python
instance. When I do this I see the results I expect. So somehow either
IPython isn't able to reload extensions modules, or I'm doing
something wrong (entirely possible!)

So, is this something I should expect to be able to do? And if so,
does anyone have any ideas on what else I should try?

On the off-chance that it makes any difference, the notebook and
"magic" implementation are here:


More information about the IPython-dev mailing list