Run And Debug Jupyter Notebook Code Cells | PyCharm - JetBrains

Run and debug Jupyter notebook code cells

You can execute the code of notebook cells in many ways using the icons on the notebook toolbar, commands in the code cell context menu and in the Structure tool window, and the Run icon in the gutter.

When you work with local notebooks, you don’t need to launch any Jupyter server in advance: execute any cell, and the server will be launched.

Run code cells

Run code cells using shortcuts and toolbar options

  • Use the following smart shortcuts to quickly run the code cells:

    • Ctrl+Enter: Runs the current cell.

    • Shift+Enter: Runs the current cell and selects the cell below it.

    When executing one cell at a time, mind code dependencies. If a cell relies on some code in another cell, that cell should be executed first.

    When the execution is done, the cell remains in the edit mode so that you can modify it, if needed, and keep experimenting.

    Press Ctrl+Home to move the caret to the start or Ctrl+End to move the caret to the end of the current cell while in edit mode.

  • To execute all code cells in your notebook, click Run all on the notebook toolbar or press Ctrl+Alt+Shift+Enter.

  • Press Ctrl+Home to focus on the fist cell or Ctrl+End to focus on the last cell of your notebook while in command mode.

Run code cells using the Structure tool window

Make sure to enable the Show Python cells in the structure view checkbox (Settings | Jupyter | Jupyter General).

  • To run a single Python cell, right-click it in the Structure tool window and select Run section Run cell.

    Run cell
  • To execute all cells within a Markdown section, right-click a Markdown cell in the Structure tool window and select Run                     section Run section.

    Run section

Duration of cell execution

  • You can find the information about the duration of a cell execution in the lower left corner of the cell.

    Hover over this area to view the date and time when the cell execution was completed.

    The information about the last cell execution

    In case of any errors, expand the Traceback node to view the complete error message.

    Error traceback

When you stop the server and change the server or kernel, you have to execute all cells with dependencies again because execution results are valid for the current server session only.

View variables

Jupyter Console

This functionality is enabled by default for both local and remote kernels. To disable it for remote kernels, go to Settings | Jupyter | Jupyter General and uncheck the Upload support libs to remote Jupyter checkbox.

When you execute your notebook, you can preview variables in the Variables tab of the Jupyter console.

Jupyter console: the Variables tab

By default, variables are loaded asynchronously. To change the loading policy, click Manage the loading policy in the Variables tab, select Variables Loading Policy, and select one of the available modes. See Managing Variables Loading Policy for more details.

You can click View as Array, View as DataFrame, View as Image, or View as Series to display the data in the corresponding tool window. For more information, refer to Work with outputs.

Jupyter Variables tool window

The Jupyter Variabes tool window will appear each time you execute a cell. If you need to hide it permanently, go to Settings | Jupyter | Jupyter General and uncheck the Show Variables tool window on execution checkbox.

Jupyter Variables tool window

Data Vision

To preview variables right in the editor, go to Settings | Jupyter | Jupyter General and make sure that the Show inline values checkbox is enabled.

  1. Run the notebook cell. The values of variables are shown next to their usages:

    Inline variables in the source editor
    Inline variables in the source editor
  2. Click the variable to view detailed information in a popup.

    Preview variables in a popup in the editor

Preview reference documentation

With PyCharm you can always quickly preview reference documentation for a particular variable, type, or argument.

  1. To view reference information for any element of a particular code cell, place the caret within the target code cell and type ? <type/variable/argument>. (in this example, you will preview documentation for plt.scatter). Note that a code element should be accessible within the code cell.

  2. Execute the cell. The Introspection tab opens in the Jupyter tool window.

    Previewing reference documentation for plt.scatter
  3. Preview reference documentation in the Introspection tab.

The Introspection tab shows documentation for the latest requested code element. Even though you proceed with executing other code cells, restart the server, or delete the line with your request, this information will be shown.

Debug code in Jupyter notebooks

PyCharm provides the Jupyter Notebook Debugger for both local and remote Jupyter server kernels.

The following debugging features are not supported for remote Jupyter servers at the moment:

  • Stepping into library code

  • Debug Console

  • Smart step into

  • Run to cursor

  • Step out

  • Debugging code with multiprocessing and threading

  • Progressive loading of large arrays

Debugging is not supported for Google Colab servers .

  1. Set the breakpoints in the selected cell and click Debug Cell Debug Cell in the cell toolbar. Alternatively, you can right-click the cell and select Debug Cell from the context menu.

    The Jupyter Notebook Debug tool window opens.

    Jupyter Notebook Debugger tool window
  2. Use the stepping toolbar buttons to choose on which line you want to stop next.

    Debugging is performed within a single code cell. However, if your code cell calls a function from any cell that has been already debugged, you can step into it. The related breakpoints will also work. Note that the cell with the function must be debugged, not just executed.

    The debugger may skip a cell if you change its source code or execute it not under the debugger. Also, you can see a warning message when trying to modify the cell code during the debugging session.

    Similarly, you can step into a function called from a Python file that is located in the same project.

  3. Proceed with the debugging steps to complete the execution of the cell.

    Debugging is complete

Stepping actions

Item

Tooltip and Shortcut

Description

Action available on the Debugger toolbar.

Step over

Step Over

F8

Click this button to execute the program until the next line in the current method or file, skipping the methods referenced at the current execution point (if any). If the current line is the last one in the method, execution steps to the line are executed right after this method.

Step into

Step Into

F7

Click this button to have the debugger step into the method called at the current execution point.

Step into my code

Step Into My Code

Alt+Shift+F7

Click this button to skip stepping into library sources and keep focused on your own code.

Step out

Step Out

Shift+F8

Click this button to have the debugger step out of the current method, to the line executed right after it.

Additional stepping actions available by clicking More stepping actions on the Debugger toolbar.

Force Step Over

Force Step Over

Alt+Shift+F8

Steps over the current line of code and takes you to the next line even if the highlighted line has method calls in it. If there are breakpoints in the called methods, they are ignored.

Force step into

Force Step Into

Alt+Shift+F7

Click this button to have the debugger step into the method called in the current execution point even if this method is to be skipped.

Smart Step Into

Smart Step Into

Shift+F7

Smart step into is helpful when there are several method calls on a line, and you want to be specific about which method to enter. This feature allows you to select the method call you are interested in.

Run to cursor

Run to Cursor

Alt+F9

Click this button to resume program execution and pause until the execution point reaches the line at the current caret location in the editor. No breakpoint is required. Actually, there is a temporary breakpoint set for the current line at the caret, which is removed once program execution is paused. Thus, if the caret is positioned at the line which has already been executed, the program will be just resumed for further execution because there is no way to roll back to previous breakpoints. This action is especially useful when you have stepped deep into the method sequence and need to step out of several methods at once.

If there are breakpoints set for the lines that should be executed before bringing you to the specified line, the debugger will pause at the first encountered breakpoint.

Use this action when you need a kind of temporary breakpoint at a specific line, where program execution should not be interrupted.

Force Run to Cursor

Force Run to Cursor

Ctrl+Alt+F9

Continues the execution until the position of the caret is reached. All breakpoints on the way are ignored.

Show Execution Point

Show Execution Point

Alt+F10

Click this button to highlight the current execution point in the editor and show the corresponding stack frame in the Frames pane.

Evaluate expression

Evaluate Expression

Alt+F8

Click this button to evaluate expressions.

23 January 2026Create and edit Jupyter notebooksWork with outputs

Tag » How To Run Ipynb File