如何从终端运行 .ipynb Jupyter Notebook? [英] How to run an .ipynb Jupyter Notebook from terminal?
问题描述
我在 .ipynb 文件中有一些代码,并且已经达到了我并不真正需要 IPython Notebook 的交互式"功能的程度.我想直接从 Mac 终端命令行运行它.
I have some code in a .ipynb file and got it to the point where I don't really need the "interactive" feature of IPython Notebook. I would like to just run it straight from a Mac Terminal Command Line.
基本上,如果这只是一个 .py 文件,我相信我可以从命令行执行 python filename.py..ipynb 文件有类似的东西吗?
Basically, if this were just a .py file, I believe I could just do python filename.py from the command line. Is there something similar for a .ipynb file?
推荐答案
从命令行,您可以使用以下命令将笔记本转换为 python:
From the command line you can convert a notebook to python with this command:
jupyter nbconvert --to python nb.ipynb
https://github.com/jupyter/nbconvert
您可能需要安装 python mistune 包:
You may have to install the python mistune package:
sudo pip install -U mistune
这篇关于如何从终端运行 .ipynb Jupyter Notebook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!