nbsphinx icon indicating copy to clipboard operation
nbsphinx copied to clipboard

How to print cell outputs when running sphinx-build in notebooks

Open dmey opened this issue 4 years ago • 5 comments

I need to debug a notebook and looking for a way to print all output to console. I tried to increase verbosity in sphinx-build but this did not help. Although the exception is captured and printed to console, nothing before/after (e.g. in a try-except-finally) is printed.

dmey avatar Apr 13 '20 16:04 dmey

I don't quite understand what you mean.

Can you please provide a minimal example?

mgeier avatar Apr 15 '20 09:04 mgeier

Assuming you have already set up a Sphinx project with nbsphinx add a cell with print('hello'), then run sphinx-build -v... My expectation was to see hello printed to stdout.

dmey avatar Apr 15 '20 09:04 dmey

OK, I see.

There is currently no way to do that.

Can nbconvert --execute do that?

mgeier avatar Apr 15 '20 09:04 mgeier

Can nbconvert --execute do that?

Running jupyter nbconvert --execute <notebook_name> does not print outputs. So I guess that this is probably related to https://github.com/jupyter/nbconvert/issues/648.

dmey avatar Apr 15 '20 09:04 dmey

Yes, it looks like that has been requested for nbconvert but there has been no solution yet, but there have been suggestions to use alternative notebook runners.

So once nbconvert can do this, nbsphinx should be able to implement it, too.

I'm also open to suggestions for using an alternative notebook runner, but I'm not planning on working on that myself.

mgeier avatar Apr 15 '20 10:04 mgeier