默认情况下如何在IPython

默认情况下如何在IPython

本文介绍了默认情况下如何在IPython Notebook代码单元格中显示行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的IPython笔记本代码单元的默认显示包含行号。

I would like my default display for IPython notebook code cells to include line numbers.

我从,我可以用ctrl-M L切换它,这很棒,但是手动。为了在默认情况下包含行号,我需要在ipython_notebook_config.py文件中添加一些内容。除非我遗漏了某些内容,否则在文档中没有解释如何执行此操作。

I learned from Showing line numbers in IPython/Jupyter Notebooks that I can toggle this with ctrl-M L, which is great, but manual. In order to include line numbers by default, I would need to add something to my ipython_notebook_config.py file. Unless I've missed something, there is not an explanation of how to do this in the documentation.

推荐答案

custom.js 文件中(位置取决于您的操作系统) )put

In your custom.js file (location depends on your OS) put

IPython.Cell.options_default.cm_config.lineNumbers = true;

如果你找不到custom.js,你可以只搜索它,但通常它会在你的profile_default文件夹中。如果它不存在,请在 $(ipython locate profile)/static/custom/custom.js

If you can't find custom.js, you can just search for it, but generally it will be in your profile_default folder. If it doesn't exist, create the file at $(ipython locate profile)/static/custom/custom.js

如果由于某种原因无效,您可以随时在 site-packages / IPython / html中编辑 custom.js 文件/ static / custom / 以同样的方式。

If for whatever reason that doesn't work, you can always edit the custom.js file in the site-packages/IPython/html/static/custom/ in the same way.

这篇关于默认情况下如何在IPython Notebook代码单元格中显示行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 08:59