I have a Jupyter
notebook and I'd like to convert it into a Python
script using the nbconvert
command from within the Jupyter
notebook.
I have included the following line at the end of the notebook:
!jupyter nbconvert --to script <filename>.ipynb
This creates a Python
script. However, I'd like the resulting .py
file to have the following properties:
- No input statements, such as:
# In[27]:
- No markdown, including statements such as:
# coding: utf-8
Ignore
%magic
commands such as:%matplotlib inline
!jupyter nbconvert --to script <filename>.ipynb
, i.e. the command within the notebook that executes thePython
conversion
Currently, the
%magic
commands get translated to the form:get_ipython().magic(...)
, but these are not necessarily recognized inPython
.