31.9 C
Texas
angeloma
Senior Writer and partner

Install Jupyter on Ubuntu 20.04

Hello friends. Having a tool like Jupyter Notebook can be something very useful that we should take into account. So in this post, you will learn how to install it.

According to the official site of the Jupyter project:

The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.

The program is run from the client web application that works in any standard browser. The prerequisite is to install and run the Jupyter Notebook server on the system. Documents created in Jupyter can be exported, among other formats, to HTML, PDF, Markdown, or Python and can also be shared with other users by e-mail, using Dropbox or GitHub, or via the integrated Jupyter Notebook viewer.

The installation is quite simple although it requires a series of steps.

- Advertisement -

So, let’s get started.

Install Jupyter Notebook on Ubuntu 20.04

Before starting, in a terminal environment, make sure Ubuntu is fully updated.

sudo apt update
sudo apt upgrade

This will get you started.

Install Python libraries and Python PIP

Next, it is necessary to install Python and some of its libraries along with PIP. To do this, run the following command

sudo apt install python3-pip python3-dev

Before using PIP it is advisable to update it so that you do not face package problems.

sudo -H pip3 install --upgrade pip

Check the new version of PIP with the command:

pip --version
pip 21.1.2 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

Now, using PIP install the virtualenv package with which we can create virtualized environments.

sudo -H pip3 install virtualenv

Now we have the requirements to proceed to install Jupyter.

Install Jupyter Notebook on Ubuntu 20.04

First, create a folder where the installation will be installed. I will call it notebook but you can choose any name.

mkdir notebook
cd notebook

Now create a new python environment, called jupyter.

virtualenv jupyter
created virtual environment CPython3.8.5.final.0-64 in 963ms
  creator CPython3Posix(dest=/home/angelo/notebook/jupyter, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/angelo/.local/share/virtualenv)
    added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

And then, activate the environment

source jupyter/bin/activate

Now yes, with the help of PIP install Jupyter

pip install jupyter

After that, run Jupyter with the following command

jupyter notebook
[I 18:39:20.257 NotebookApp] Writing notebook server cookie secret to /home/angelo/.local/share/jupyter/runtime/notebook_cookie_secret
[I 18:39:20.570 NotebookApp] Serving notebooks from local directory: /home/angelo/notebook
[I 18:39:20.570 NotebookApp] Jupyter Notebook 6.4.0 is running at:
[I 18:39:20.570 NotebookApp] http://localhost:8888/?token=78f2898d7e50f76247a54d04de84f70ff9c157f71e4f3275
[I 18:39:20.570 NotebookApp]  or http://127.0.0.1:8888/?token=78f2898d7e50f76247a54d04de84f70ff9c157f71e4f3275
[I 18:39:20.570 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 18:39:20.574 NotebookApp] No web browser found: could not locate runnable browser.

On the output screen, you will have the information that you can access from the browser but we can configure Jupyter to make it more secure and personal.

Configuring Jupyter

Press the CTRL + C keys to finish running Jupyter.

Once you have done this, generate a default configuration file by running:

jupyter notebook --generate-config
Writing default config to: /home/angelo/.jupyter/jupyter_notebook_config.py

Then, modify it so that you can access it from any host or network. If you will be using Jupyter on your computer locally, skip this step.

nano /home/angelo/.jupyter/jupyter_notebook_config.py

Find the c.NotebookApp.allow_remote_access line and set it to True.

c.NotebookApp.allow_remote_access = True

Save the changes and close the editor.

Then, generate a password that will help us to secure the Jupyter instance.

jupyter notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /home/angelo/.jupyter/jupyter_notebook_config.json

Now run it and from a web browser, you will be able to log in.

1.- Access to Jupyter
1.- Access to Jupyter

After entering the password you have defined, you can start working.

2.- Jupyter on Ubuntu 20.04
2.- Jupyter on Ubuntu 20.04

Enjoy it.

Conclusion

Jupyter is a very productive tool that we can easily install on any computer thanks to PIP. This way we can take advantage of its features and make it our own.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article