Jupyter Notebook, create and share documents from Ubuntu 20.04

about Jupyter Notebook

In the following article we are going to take a look at how we can install Jupyter Notebook on Ubuntu 20.04. This is an open source web application that it will allow users to create and share documents that contain source code, equations, visualizations and narrative text, among other things.

This program runs from the client’s web application, which works in any standard browser. The prerequisite is to install and run the Jupyter Notebook server on our system. Documents created in Jupyter can be exported to formats such as HTML, PDF, Markdown, or Python. In addition, they can also be shared with other users by email, using Dropbox or GitHub, or through the integrated Jupyter Notebook viewer.

This application is generally designed for advanced Python compatibility. It also includes the possibility of exporting documents made with the tool to other formats. The general purpose for which this tool was created is to be used in learning the Python programming language. We can also obtain cleaning and transformation of scientific data, numerical simulation or statistical modeling. These are just some of the areas with which we can work with this application.

Install Jupyter Notebook on Ubuntu 20.04

Installation is quite simple, although it requires a series of steps. To begin we are going to open a terminal (Ctrl + Alt + T), now make sure Ubuntu is fully up to date:

sudo apt update; sudo apt upgrade

Install the necessary requirements

Now we are going to install Python and some of its libraries along with PIP. To do this, in the same terminal we will only need to execute the command:

install python 3 pip

sudo apt install python3-pip python3-dev

Before using PIP, it is advisable to update it so as not to have problems with the packages:

update pip

sudo -H pip3 install --upgrade pip

Once installed and updated, we can check version of PIP installed with the command:

pip version installed

pip --version

At this point, using PIP let’s install the package virtualenv with which we can create virtualized environments:

install virtualenv

sudo -H pip3 install virtualenv

Install Jupyter Notebook

Now that we have the necessary requirements to install Jupyter Notebok, first we are going to create a folder where the installation will be installed. I’m going to call this Jupyter, but it can be given any other name.

mkdir jupyter

cd jupyter

Now let’s create a new Python environment:

create virtual environment for Jupyter Notebook

virtualenv jupyter

Then we will activate environment running the command:

source jupyter/bin/activate

At this point, with the help of PIP, we can now install Jupyter Notebook:

pip install jupyter

pip install jupyter

After the installation, we have run jupyter server with the command:

run jupyter server

jupyter notebook

On the exit screen, you will have the information that you can access from the web browser. But before we get to work with this program, we can configure Jupyter a bit to make it a bit more secure.

Basic configuration

To close the server that we started with the previous command, we only need to press the key combination Ctrl + C. Once this is done, we will generate a default configuration file running:

Jupyter Notebook setup

jupyter notebook --generate-config

Then we are going to modify it a bit so that we can access Jupyter Notebook from any host or network. If you are going to use Jupyter on your computer locally, skip this step. To modify the configuration file, we just need our favorite editor and use a command like the following:

vim ~/.jupyter/jupyter_notebook_config.py

Inside the file we will have to look for the line c.NotebookApp.allow_remote_access and set its value to True.

enable jupyter network

c.NotebookApp.allow_remote_access = True

Once this is done, save the changes and close the editor.

Back in the terminal, let’s generate a password that will help us protect access to our Jupyter installation.

set password

jupyter notebook password

Yes now we rerun the Jupyter service with the command:

jupyter notebook

We will be able to access our facility again, but before we will need to log in with the password we just set. Then we can start working.

jupyter notebook password web

Jupyter Notebook is a very useful tool for those who are starting in the world of programming with Python. It also has great potential for those who want to study data science in an orderly manner.

jupyter interface

If you want to test this program before installing any package on our computer, you can use the online demo that its creators make available to users. In addition we will also have at our disposal a extensive documentation of all its functionalities from its official website. If you are interested in taking a look at the source code of the project, it can be consulted from its repository on GitHub.

Add Comment