Because notebooks are hard to version control - try git diff [YOUR_NOTEBOOK].ipynb
after a few changes and see the mess.
- Most obvious way is to manually download from the notebook:
File -> Download as -> Python (.py)
, find the python file from the Downloads folder, and copy to your repository. - A slightly better way is to run from the command line:
$ jupyter nbconvert --to script [NOTEBOOK_NAME].ipynb
or run the schell command in jupyter notebook:
!jupyter nbconvert --to script [NOTEBOOK_NAME].ipynb
Follow this post and save this python file (jupyter_notebook_config.py
) as ~/.jupyter/jupyter_notebook_config.py
.
How to automatically save a jupyter notebook as a python file when you're running the notebook in a docker container?
Add jupyter_notebook_config.py
to the .jupyter
folder in the dockerfile:
ADD jupyter_notebook_config.py [HOME]/.jupyter/
See here for example.