Jupyter Notebook的“ hidecode”标签不起作用?

时间:2019-03-14 22:54:30

标签: jupyter

我正在尝试使用here所示的hidecode标签,但是由于某些原因,它在我的本地Jupyter Notebook服务器上不起作用。该代码仍然可见,并且该单元格右侧不显示任何按钮。我什至下载了以上页面中使用的same notebook,没有骰子。

我正在运行Ubuntu 18.04.2 LTSJupyter Notebook Server 5.2.2Python 3.6.7IPython 5.5.0。我运行的启动服务器的命令是sudo jupyter notebook --allow-root

如果您需要更多信息,请告诉我。感谢您在解决此问题方面所能提供的帮助。

1 个答案:

答案 0 :(得分:0)

如果要隐藏代码,单元格的输出或提示,可以安装 hide_code 扩展名:

https://pypi.org/project/hide_code/0.2.0/

  1. 停止jupyter
  2. 运行这些命令

pip install hide_code

jupyter nbextension install --py hide_code

jupyter nbextension enable --py hide_code

jupyter serverextension enable --py hide_code

注意:我以 root 身份运行前两个命令,后两个命令使用相同的用户来启动jupyter。

  1. 重新启动jupyter

我发现此扩展非常有用,因为我需要将笔记本打印为pdf文件,并且所有工具(如nbpublish,nbconvert)都失败了。这样,我可以直接从浏览器的“打印”功能中打印笔记本。