Introduction
Jupyter Notebook is a web-based interactive platform for exploring data features and developing models widely used by data scientists and machine learning engineers. It’s a type of document that contains code and its output as well as visualizations, narrative text, mathematical equations, and other rich media. By using Notebook, we can streamline our workflow, communicate more effectively, and share our results easily.
Installing Jupyter Notebook
Getting started with Jupyter Notebook is easy if you install Anaconda.
- Prepare Directory
mkdir -p ~/tools/ananconda/ && cd ~/tools/ananconda/
- Download Anaconda
curl https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh -o anaconda.sh
- Install Anaconda
exec bash && chmod +x anaconda.sh && ./anaconda.sh -u
After this follow output instructions and do setup properly.
Default Environment
By default, anaconda base
environment is preloaded with all the most popular libraries and tools. You can use this environment if you want hassle-free environment to get start quickly.
- Create root directory where we want to store your all notebooks.
mkdir -p ~/tools/ananconda/default
- Launch Jupyter Notebook
cd ~/tools/ananconda/default && jupyter notebook
Your default web browser should open a new tab that looks like the following screenshot:
Launch Jupyter Notebook
To launch notebook run following command:
jupyter notebook
Your default web browser should open a new tab that looks like the following screenshot:
Creating Example Notebook
First, click the New
drop-down button in the top-right and select Python 3
:
Running Example Notebook
Once you click on it, you will see new file with Untitled
title. By adding cell you can write code and then clicking on Run
button produces output of your code as like below screenshot:
Setup Custom Anaconda Environment
Sometimes, we want separate environment with specific dependencies then custom environment is very useful.
- Create root directory where we want to store your all notebooks.
mkdir -p ~/tools/ananconda/notebooks
- Prepare conda environment configuration
cd ~/tools/ananconda/notebooks
filename=environment.yml
cat > $filename <<EOT
name: notebooks
dependencies:
- pip=20.2.4=py38h06a4308_0
- pip:
- jupyterlab==4.0.0a19
EOT
- Setup environment
conda env create -f environment.yml
- Activate environment
conda activate notebooks
- Launch Jupyter Notebook
jupyter notebook
- Adding dependencies in environment
filename=environment.yml
cat > $filename <<EOT
name: notebooks
dependencies:
- pip=20.2.4=py38h06a4308_0
- pip:
- jupyterlab==4.0.0a19
- tensorflow==2.6.0
EOT
- Update environment
conda env update
- Deactivate environment
conda deactivate
Thank you! for reading this article.