I am using nbconvert.
From the SimpleNotebook.ipynb, I want to output two file:
My command line for doing the job:
jupyter nbconvert SimpleNotebook.ipynb --to notebook --execute
jupyter nbconvert SimpleNotebook.ipynb --to html --execute --no-input
output console
[NbConvertApp] Converting notebook SimpleNotebook.ipynb to notebook
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] Writing 18547 bytes to SimpleNotebook.nbconvert.ipynb
[NbConvertApp] Converting notebook SimpleNotebook.ipynb to html
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] Writing 280188 bytes to SimpleNotebook.html
It created
SimpleNotebook.nbconvert.ipynb (a notebook with output cell)
SimpleNotebook.html (the web output)
jupyter nbconvert SimpleNotebook.ipynb --to notebook --execute --no-input jupyter nbconvert SimpleNotebook.ipynb --to html --execute --no-input
The problem: It run twice. As I can see in the console output:
[NbConvertApp] Executing notebook with kernel: python3
Happen twice, because it execute notebook again for each command line.
I would like to output both file SimpleNotebook.nbconvert.ipynb and SimpleNotebook.html but only execute the notebook once. How should I write the command line ?
You don't want --execute
in your second command. And make sure to use the output of the first command as the input for the second.
The following would replace your two commands using your example:
jupyter nbconvert SimpleNotebook.ipynb --to notebook --execute
jupyter nbconvert SimpleNotebook.nbconvert.ipynb --to html --no-input