How to Install Jupyter Notebook on Ubuntu

29/12/2020
Chưa phân loại
Jupyter Notebook is one of the most widely used tool to execute Python interactively directly from a browser. With Jupyter Notebooks, we have an excellent opportunity to mix code with interactive exercises and documentation which doesn’t restrict us to keep our comments with # symbol and also allows to see the output of small snippet of our code directly in our browser. With the IPython 4.0 release, the language-independent parts of the project: the notebook style, message protocol, qtconsole, notebook web application, etc. have moved to a new project under the name Jupyter.

In this lesson, we will setup the Jupyter Notebook server on a Ubuntu machine and also connect to the Jupyter server as well with which we will be able to make new Jupyter Notebooks and run some sample Python code as well.

Getting Started

We will start by installing most basic components for this lesson which are Python and PIP. Let’s start with basic updates in our machine:

sudo apt-get update

Here is what we get back with this command:

Update machine

Next, we can install required components in a single command:

sudo apt-get -y install python2.7 python-pip python-dev

This installation might take some time to install depending on network speed as many dependencies are being installed here. We are using Python 2.7 with PIP package manager with which we can use and install many other python modules as we go. Finally, many of Jupyter’s dependencies work on Python-C extension, so we installed the python-dev dependency as well. To verify that everything went well, let us check the Python & PIP version with these commands:

python –version
pip –version

We will get back:

Python & PIP Version

Installing IPython & Juptyr

We can move on to installing most important parts of this lesson. Let us run the following commands to install IPython & Juptyr on our machine:

sudo apt-get -y install ipython
sudo -H pip install jupyter

Again, even this command can take more time to complete depending on network speed. Once this command is complete running, we can finally start the jupyter notebook as:

jupyter notebook –allow-root

You can start Jupyter as a non-root user as well. If you start Jupyter as a root user, we will have to use the –allow-root flag. Once this starts, the terminal will look like this:

Start Jupyter

Accessing Jupyter Console

We can access the Jupyter server from the URL shown in the console. If you’re running this server on a remote server, we will have to tunnel into the IP through SSH. We can do this with this command:

ssh -L 8000:localhost:8888 your_server_username@your_server_ip

Once you execute this command, you can again SSH into your server and execute the command to start Jupyter notebook with this command:

jupyter notebook –allow-root

Accessing Jupyter Notebook

Once you’ve started the Jupyter notebook server through SSH, you will see a URL like this in the terminal window:

http://localhost:8888/?token=8acc13e5fa48059e8ba0512bb54c616ed8ea100d5e25f639&token=8acc13e5fa48059e8ba0512bb54c616ed8ea100d5e25f639

Take note of one of the tokens in the URL. Now, open the following URL in your local machine browser:

http://localhost:8000/

You will see something like:

Accessing Jupyter

Once you’re in this screen, we can input the token we collected in previous step in the provided field. We will be inside once we hit Enter. We will see a screen like this:

Jupyter Notebook

We can now create a new notebook:

Creating new notebook

We can provide a name to this notebook by clicking on title bar:

Naming a Notebook

Finally, you can write sample Python code and execute in the browser itself:

Execute Python notebook

Conclusion

In this lesson, we looked at how we can install and start using Jupyter notebook server on Ubuntu 18.04 machine.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Installing PlayOnLinux on Debian 10

PlayOnLinux is a graphical frontend of Wine, the Windows compatibility layer for Linux. Wine is used to install and run...
29/12/2020

NLTK Tutorial in Python

The era of data is already here. The rate at which the data is generated today is higher than ever and it is always growing....
29/12/2020

Visual Studio Code 1.14 Now Ships with TypeScript 2.4

Microsoft Visual Studio Code 1.14 recently released, is an open-source code editor every developer needs for their core...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024