jupytext 同步.ipynb与.py文件方便git管理

1. 安装jupytext文件,

python3 -m pip install jupytext --user;

2. 生成修改jupyter notebook配置文件

jupyter notebook --generate-config -y
echo 'c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"' >> ~/.jupyter/jupyter_notebook_config.py

3. 将jupytext添加到对应路径中,export PATH=$PATH:/Users/XXXX/Library/Python/3.7/bin;

4.  jupytext --to py abc.ipynb 生成对应的abc.py文件;

5. 将"jupytext": {"formats": "ipynb,py"}添加到jupyter notebook--jupyter界面--打开对应的abc.ipynb-编辑--编辑界面原数据的文件中。注意不要修改其它的配置;

 

这样.py与.ipynb文件就可以同步了。只要git管理.py文件即可。

 

参考文献:https://nextjournal.com/schmudde/how-to-version-control-jupyter

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章