Image: Illustration from A Personal Computer for Children of All Ages. ACM, Boston, Alan Kay, 1972. Because you use Jupyter in a web browser, some people are understandably concerned about using. The landing page of the Jupyter notebook web application.
With Jupyter Notebook integration available in PyCharm, you can easily edit, execute, and debug notebook source code and examine execution outputs including stream data, images, and other media.
Notebook support in PyCharm includes:
Editing and preview:
Ability to present a notebook as source code with textual cell definitions and manipulate cells as regular code.
Live preview of the cell execution output and Markdown content.
Auto-saving changes that you make in your files. Saving is triggered by various events, for example, closing a file or a project, or quitting the IDE.
Coding assistance:
Error and syntax highlighting.
Code completion.
Ability to create line commentsCtrl+/.
Ability to run cells and preview execution results.
Dedicated Jupyter Notebook Debugger.
Shortcuts for basic operations with Jupyter notebooks.
Ability to recognize .ipynb files and mark them with the icon.
Quick start with the Jupyter notebook in PyCharm
To start working with Jupyter notebooks in PyCharm:
Create a new Python project, specify a virtual environment, and install the jupyter package.
Open files in your.
If needed, configure or create a new virtual environment.
Open or create an .ipynb file.
Add and edit source cells.
Execute any of the code cells to launch the Jupyter server.
Analyze execution results in the Preview pane.
Get familiar with the user interface
Mind the following user interface features when working with Jupyter notebooks in PyCharm.
Notebook editor
In PyCharm, you can work with Jupyter notebook files using three viewing modes:
In this mode, you can add notebook cells and edit them.
In this mode, you can both edit cells and preview their output. This is the default viewing mode for Jupyter notebooks in PyCharm.
In this mode, you can preview markdown and raw cells as well as code cell execution results.
Editing and preview modes reflect the currently selected PyCharm user interface appearance.
Notebook toolbar
The Jupyter notebook toolbar provides quick access to all basic operations with notebooks:
Opens the Jupyter Quick List for easy access to the basic notebook operations:
|
---|
Executes all cells in the notebook. |
Click this icon if you want to interrupt any cell execution. |
Click this icon to restart the currently running kernel |
Upload to Datalore/Update uploaded notebook. Enables sharing the selected Jupyter notebook using Datalore, an intelligent web application for data analysis. Click this button to start sharing the current notebook file. Once you modify the notebook file, this button enables updating the shared notebook in Datalore. |
The Jupyter Server widget that shows the currently used Jupyter server. Click the widget and select Configure Jupyter Server to setup another local or remote Jupyter server. |
List of the available Jupyter kernels. |
Select this checkbox to allow executing JavaScript in your Jupyter notebook. |
This actions moves the current cell up. |
This actions moves the current cell down. |
You can preview the notebook in a browser. |
Enables auto scrolling from the source cell in the Editor to the corresponding output in the Preview pane. |
Enables auto scrolling from the cell output in the Preview pane to the corresponding source cell in the Editor. |
Click this icon to show source code fragments in the Preview pane. |
Click this icon to switch into the editor only viewing mode. |
Click this icon to show both Editor and the Preview pane. |
Click this icon to switch into the preview only mode. |
Tool windows
The Server Log tab of the Jupyter tool window appears when you have any of the Jupyter server launched. The Server log tab of this window shows the current state of the Jupyter server and the link to the notebook in a browser.
It also provides controls to stop the running server () and launch the stopped server ( ).
The Variables tab provides the detailed report about variable values of the executed cell.
You can use the icon to manage the variables loading policy.
Markdown Formatting
The five most important concepts to format your code appropriately when using markdown are:
- Italics: Surround your text with ‘_’ or ‘*’
- Bold: Surround your text with ‘__’ or ‘**’
inline
: Surround your text with ‘`’blockquote: Place ‘>’ before your text.
- Links: Surround the text you want to link with ‘[]’ and place the link adjacent to the text, surrounded with ‘()’
Headings
Notice that including a hashtag before the text in a markdown cell makes the text a heading. The number of hashtags you include will determine the priority of the header (‘#’ is level one, ‘##’ is level two, ‘###’ is level three and ‘####’ is level four).
H2
H3
H4
H5
H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H2
Emphasis
Emphasis, aka italics, with asterisks or underscores.
Strong emphasis, aka bold, with asterisks or underscores.
Combined emphasis with asterisks and underscores.
Strikethrough uses two tildes. Scratch this.
Lists
There are three types of lists in markdown.
Ordered list:
- Step 1
- Step 1B
- Step 3
Unordered list
- CESM-POP
- CESM-MOM
- CESM-CAM
Task list
- Learn Jupyter Notebooks
- Writing
- Modes
- Other Considerations
- Submit Paper
NOTE:
Double click on each to see how they are built!
Images
Here’s our logo (hover to see the title text):
Inline-style:
Reference-style:
Code and Syntax Highlighting
Code blocks are part of the Markdown spec, but syntax highlighting isn’t. However, many renderers – like Github’s and Markdown Here – support syntax highlighting. Markdown Here supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the highlight.js demo page.
Inline code
has back-ticks around
it.
Blocks of code are either fenced by lines with three back-ticks ```
, or are indented with four spaces. I recommend only using the fenced code blocks – they’re easier and only they support syntax highlighting.
Again, to see what languages are available for highlighting, and how to write those language names, see the highlight.js demo page.
Tables
Tables aren’t part of the core Markdown spec, but they are part of GFM and Markdown Here supports them.
Colons can be used to align columns.
Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
Blockquotes
Blockquotes are very handy in email to emulate reply text.This line is part of the same quote.
Quote break.
This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can putMarkdown into a blockquote.
Inline HTML
You can also use raw HTML in your Markdown, and it’ll mostly work pretty well.
- Definition list
- Is something people use sometimes.
- Markdown in HTML
- Does *not* work **very** well. Use HTML tags.
Horizontal Rule
Three or more…
Hyphens
Asterisks
Underscores
Line Breaks
My basic recommendation for learning how line breaks work is to experiment and discover – hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You’ll soon learn to get what you want. “Markdown Toggle” is your friend.
Here are some things to try out:
Here’s a line for us to start with.
This line is separated from the one above by two newlines, so it will be a separate paragraph.
This line is also begins a separate paragraph, but…This line is only separated by a single newline, so it’s a separate line in the same paragraph.

(Technical note: Markdown Here uses GFM line breaks, so there’s no need to use MD’s two-space line breaks.)
YouTube Videos
They can’t be added directly but you can add an image with a link to the video like this:
Or, in pure Markdown, but losing the image sizing and border:
TeX Mathematical Formulae
A full description of TeX math symbols is beyond the scope of this cheatsheet. Here’s a good reference, and you can try stuff out on CodeCogs. You can also play with formulae in the Markdown Here options page.
Here are some examples to try out:
The beginning and ending dollar signs ($
) are the delimiters for the TeX markup.
Rendered Tex:
$-b pm sqrt{b^2 - 4ac} over 2a$$x = a_0 + frac{1}{a_1 + frac{1}{a_2 + frac{1}{a_3 + a_4}}}$$forall x in X, quad exists y leq epsilon$
Code Capabilities
Code cells are different than Markdown cells in that they have an output cell. This means that we can keep the results of our code within the notebook and share them. Let’s say we want to show a graph that explains the result of an experiment. We can just run the necessary cells and save the notebook. The output will be there when we open it again! Try it out by running the next four cells.
We can also print images while experimenting.
- Even videos:
Shortcuts and tricks
Command Mode Shortcuts
There are a couple of useful keyboard shortcuts in Command Mode
that you can leverage to make Jupyter Notebook faster to use. Remember that to switch back and forth between Command Mode
and Edit Mode
with Esc and Enter.
m: Convert cell to Markdown
y: Convert cell to Code
D+D: Delete cell
o: Toggle between hide or show output
Shift+Arrow up/Arrow down: Selects multiple cells. Once you have selected them you can operate on them like a batch (run, copy, paste etc).
Draw A Horizontal Line In Jupyter Notebook
Shift+M: Merge selected cells.
Shift+Tab: [press once] Tells you which parameters to pass on a function
Shift+Tab: [press three times] Gives additional information on the method
Cell Tricks
- There are also some tricks that you can code into a cell.
?function-name
: Shows the definition and docstring for that function
??function-name
: Shows the source code for that function
Line Magics
Line magics are functions that you can run on cells and take as an argument the rest of the line from where they are called. You call them by placing a ‘%’ sign before the command. The most useful ones are:
%matplotlib inline
: This command ensures that all matplotlib plots will be plotted in the output cell within the notebook and will be kept in the notebook when saved.
%reload_ext autoreload
, %autoreload 2
: Reload all modules before executing a new line. If a module is edited, it is not necessary to rerun the import commands, the modules will be reloaded automatically.
These three commands can be called together at the beginning of every notebook.
%timeit
: Runs a line multiple times and displays the average time it took to run it.
Ln In Jupyter Notebook
%debug
: Allows to inspect a function which is showing an error using the Python debugger.
