Fix Python – Showing line numbers in IPython/Jupyter Notebooks

Question

Asked By – Ruggero Turra

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 indicated in Notebooks.

Is it possibile to add the line numbers to IPython/Jupyter Notebooks?

Now we will see solution for issue: Showing line numbers in IPython/Jupyter Notebooks


Answer

CTRLML toggles line numbers in the CodeMirror area. See the QuickHelp for other keyboard shortcuts.

In more details CTRLM (or ESC) bring you to command mode, then pressing the L keys should toggle the visibility of current cell line numbers. In more recent notebook versions Shift-L should toggle for all cells.

If you can’t remember the shortcut, bring up the command palette Ctrl-Shift+P (Cmd+Shift+P on Mac), and search for “line numbers”), it should allow to toggle and show you the shortcut.

This question is answered By – minrk

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0