Close Navigation
Learn more about IBKR accounts
Jupyter Notebook Tutorial: Installation, Components and Magic Commands – Part I

Jupyter Notebook Tutorial: Installation, Components and Magic Commands – Part I

Posted February 2, 2023
Jay Parmar
QuantInsti

This article on Jupyter Notebooks (previously known as IPython Notebooks), does not require any pre-requisite knowledge and does not assume any familiarity with the framework. This blog is an introductory article where I will primarily address the following questions:

  • What is Jupyter Notebook?
  • How to install the Jupyter Notebook environment?
  • How to run or open Jupyter Notebook?
  • What are the different components of Jupyter Notebook?
  • What are cells in a Jupyter Notebook?
  • How to write in Markdown language?
  • What are the magic commands in Jupyter Notebook?
  • How to download and share Jupyter Notebook?

After reading this blog, you will be able to:

  • Install the Jupyter Notebook environment
  • Open Jupyter Notebook
  • Understand various components
  • Download and share Juypter Notebooks

Along with the above questions, you will also learn writing in Markdown language in Jupyter notebooks. Let’s get started with the first question.

What is Jupyter Notebook?

If you are a student, you must be using a class notebook to take various class notes, or if you are a business professional, you might be using a writing pad to pen down important notes, either for your purpose or to present to someone else.

The typical content that goes in a student’s notebook can be text in various formats such as bold and italic, or a table, a mathematical equation, or creative stuff like hand-drawn images and so on. Not to forget that if it’s a programmer’s notebook, it will also contain a lot of programming code.

Now, you want to continue with this practice of writing all such stuff in a single place online. Jupyter notebook comes to the rescue here. It is a web-based platform that allows you to write narrative text in various formats, include a table or an image, write equations and code in various programming languages, all in one place.


How to install Jupyter environment?

jupyter notebook

If the above command fails, you can continue reading this section. Otherwise, you can safely skip this and proceed to the next section. In case the command fails and you get the error similar (not exact) to the one shown below, continue with this section to understand the installation process.

Two popular methods using which Python can be installed on your workstation. They are

  1. Installing Python using Anaconda Distribution
  2. Installing Raw Python

While Jupyter runs code in many programming languages, Python is a requirement for installing the Jupyter Notebook.

Installing Jupyter Notebook using Anaconda

If you have installed Python using Anaconda Distribution, you are good to go. Anaconda Distribution includes Python, the Jupyter Notebook, and other commonly used packages for the scientific community.

If you don’t have any version of Python installed, the recommended way to install Python is using Anaconda Distribution. It should be pretty simple to get Python installed.

  • First, download the latest version of Anaconda Distribution.
  • Second, install the downloaded version of Anaconda.

Bam! You have installed Jupyter Notebook. To check whether the installation is successful or not, and run the Jupyter Notebook, run the following command in the Anaconda prompt or command prompt (Windows) or terminal (Mac/Linux).

jupyter notebook

If you get an error upon running the above command (which should not happen), try the following method.

Installing Jupyter Notebook using pip

When you install Python directly from its official website, it does not include Jupyter Notebook in its standard library. In this case, you need to install Jupyter Notebook using the pip. The process is as follows:

  1. Open a new command prompt (Windows) or terminal (Mac/Linux)
  2. Execute the following command to install Jupyter Notebook
python -m pip install jupyter

or if you are using Python 3

python3 -m pip install jupyter

or simply

pip install jupyter

Congratulations, you have installed Jupyter Notebook! Onward to running it.

How to run or open Jupyter Notebooks?

After you have installed the Jupyter Notebook on your computer, you are ready to run the notebook server.

If you are reading this article from the beginning, then you might already know how to run Jupyter Notebook. However, if you have skipped the previous sections and directly jumped here, the below mentioned steps shows how to run the Jupyter Notebook.

First, open a new command prompt (Windows) or terminal (Mac/Linux) on your workstation, and second, execute the following command:

jupyter notebook

Upon executing the above command, the terminal or command prompt will print some information about the Jupyter Notebooks being loaded. It might look something like as shown in the below snapshot. Be mindful that the information printed would be different for each workstation.

Keep the terminal open as it is. It will then open the default web browser with the URL mentioned in the command prompt or terminal.

When the notebook opens in your browser, you will see the Notebook Homepage as shown in the below snapshot. This will list the notebook files and subdirectories in the directory where the notebook server was started.

 class=

In case you are using Anaconda distribution for Python, you can open Anaconda Navigator (using the Start Menu(Windows), Applications folder(Mac), or Softwares folder(Linux)) shown below which allows you to open Jupyter Notebook using point and click.

Once the Navigator application is open, you can click on the Launch button within the Notebook dialogue to launch the Jupyter Notebook application. Upon clicking the Launch button, you will be presented by the homepage that we’d seen earlier.

Now, let’s understand how Jupyter environment works, I won’t be going technical, though. As the Jupyter Notebook is a web application, it works on a server-client architecture. When you execute the command jupyter notebook, the Jupyter software starts the server locally in the console where the command is executed, and the Jupyter Notebook homepage that opens in the web browser works as the client. Whatever you perform, that is, create or upload a new notebook, or save the existing one, the client notebook on which you are working, will keep communicating with the server running in the console/command line.

To keep notebooks running smoothly, we need to keep the command prompt or terminal open, even after it has opened homepage. If you close it, notebooks that you are working with, won’t be able to communicate with the local server, and hence, any work you do, will not be saved on persistent memory.

The next step is to learn various components of Jupyter software.

Stay tuned for the next installment to learn about the different components of Jupyter notebooks.

Originally posted on QuantInsti Blog: https://blog.quantinsti.com/jupyter-notebook-tutorial-installation-components-magic-commands/.

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from QuantInsti and is being posted with its permission. The views expressed in this material are solely those of the author and/or QuantInsti and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.