Installing Jupyter Python Notebook For Python 2 and 3

Pip is the default package management system or tool for installing/uninstalling and managing different packages in Python. It provides an OS independent system, so you can use it for any of the operating systems like Windows, Linux (Ubuntu), MacOS, etc…

You can install the Jupyter Notebook from the Python standard library with simple commands.

Python 3.7

py -m pip install --upgrade pip
py -m pip install jupyter

Here, the first command is to upgrade the pip. It is always good practice to upgrade pip before installing any Python module.

Python 2

Jupyter creates the localhost server to execute the Python programs. Running Jupyter notebook command will open the notebook page in the new tab of the browser as localhost.

How to Write and Run Jupyter Python Notebook | Your First Program

You can see the local directories in your browser notebook.

Follow the steps for Writing Your First Python Program in Notebook:

Select the directory where do you want to save the Jupyter notebook program.

Then click on the new drop-down menu option (right-top option).

Select the Python version. (Here I have installed notebook for Python 3).

It will open the new tab in your browser where you can write your first program.

Write your Python code and run.

You can rename the Jupyter file by double-clicking on it. I have renamed it to testProg.

In above Image, you can see the different cell where you can split your code.

It’s pretty easy to execute Python program, isn’t it? You don’t need to execute any command line code. Just click on Run, you have done with your Job.

Let’s find little more about using different types of cell in Jupyter.

Different Types of Cell in Jupyter Python Notebook

There are majorly three types of cell in Jupyter.

Code:

This cell is to write and execute actual Python code.

Markdown:

This is advance feature comes with Jupyter where you can write simple HTML commands to decorate the text inside the browser.

Heading:

As its name, with this cell, you can add heading to your Python Jupyter program. If your program has a large number of lines and cells, it is good practice to add headings. It is easy for understanding and maintaining Python code.

Keynotes for Using Python Jupyter Notebook

You can add as many cells in the file before and after the selected cell.

You can mark each cell with different tags – Code, Markdown, Heading.

Only lines from the code cell will be executed.

To run cell – select the cell and then click on “Run”

You can see the output of the program just below the code cell.

That’s all from this tutorial to install and run Jupyter Python Notebook.

Advantages of Using Jupyter Notebook

Once you start using it, you will just love. Running Python program in Jupyter is pretty easy in the browser as compared to running Python code in the different text editor. You don’t need to run command every-time to execute the code.

If you are writing or practicing coding, adding explanatory comments for your code will help. Many of the Python tutors use Jupyter in their classroom to teach Python and other programming languages. Even I am using Jupyter in my Data Science course.

This article had covered all the detail required to execute your Python code in the Jupyter notebook. For more detail, you can visit Jupyter Official website.

I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.