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

Hướng dẫn cài đặt LEMP stack trên CentOS 8

LEMP là một nhóm các phần mềm có thể dùng để phục vụ các web động được viết bằng PHP. LEMP...
30/12/2020

Những điều tâm đắc nhất khi sử dụng lệnh GREP

Grep (Global Regular Expression Print) là một công cụ dòng lệnh Linux/Unix được sử dụng để tìm kiếm...
30/12/2020

Install LLVM on Ubuntu

Install LLVM 5 on Ubuntu 17.10 Artful Aardvark LLVM is a C/C++ compiler toolset just like GCC. LLVM can compile C, C++...
28/12/2020
Bài Viết

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

Huớng dẫn dùng proxy cho ios, iphone 2023
23/09/2023

Cách gắn set proxy cho điện thoại android, oppo, giả lập android, Ldplayer Bằng Proxydroid
20/09/2023

Mua Proxy Socks5 VN Chơi Game Gia Lập Tăng Cường Trải Nghiệm Chơi Game
22/06/2023

Mua Proxy Mỹ, Us Nuôi Tài Khoản Etsy, eBay Tìm Hiểu Về Mua Proxy Mỹ tại Onet.com.vn
22/06/2023

Mua Proxy Game – Giải pháp tuyệt vời cho việc chơi game trên mạng mà không bị giới hạn về vị trí địa lý
03/06/2023