Showing line numbers in IPython/Jupyter Notebooks

后端 未结 10 1182
遥遥无期
遥遥无期 2020-12-04 05:56

Error reports from most language kernels running in IPython/Jupyter Notebooks indicate the line on which the error occurred; but (at least by default) no line numbers are in

相关标签:
10条回答
  • 2020-12-04 06:21

    1.press esc to enter the command mode 2.perss l(it L in lowcase) to show the line number

    0 讨论(0)
  • 2020-12-04 06:23

    To turn line numbers on by default in all cells at startup I recommend this link. I quote:

    1. Navigate to your jupyter config directory, which you can find by typing the following at the command line:

      jupyter --config-dir
      
    2. From there, open or create the custom folder.

    3. In that folder, you should find a custom.js file. If there isn’t one, you should be able to create one. Open it in a text editor and add this code:

      define([
          'base/js/namespace',
          'base/js/events'
          ],
          function(IPython, events) {
              events.on("app_initialized.NotebookApp",
                  function () {
                      IPython.Cell.options_default.cm_config.lineNumbers = true;
                  }
              );
          }
      );
      
    0 讨论(0)
  • 2020-12-04 06:23

    Was looking for this: Shift-L in JupyterLab 1.0.0

    0 讨论(0)
  • 2020-12-04 06:24

    On IPython 2.2.0, just typing l (lowercase L) on command mode (activated by typing Esc) works. See [Help] - [Keyboard Shortcuts] for other shortcuts.

    Also, you can set default behavior to display line numbers by editing custom.js.

    0 讨论(0)
  • 2020-12-04 06:24

    Here is how to know active shortcut (depending on your OS and notebook version, it might change)

    Help > Keyboard Shortcuts > toggle line numbers

    On OSX running ipython3 it was ESC L

    0 讨论(0)
  • 2020-12-04 06:27

    In Jupyter Lab 2.1.5, it is View -> Show Line Numbers.

    0 讨论(0)
提交回复
热议问题