Installing a Jupyter Notebook on a Compute instance running OEL8 on OCI

On my last blog post, I described the steps to install a jupyter lab notebook on a local machine running MacOS.

This post will describe the steps to install a Jupyter lab on a compute instance running on Oracle Enterprise Linux 8 (OEL8) on Oracle cloud infrastructure.

Step 1: SSH to the the instance

ssh -i dev-instance-private.key opc@141.147.xx.xxx

Step 2: update and install Dependencies: (use dnf cmd for Oracle linux 8, yum for linux 7 and below)

sudo dnf update -y

Step 3: Install python and pip

  sudo dnf install python3 -y
  sudo dnf install python3-pip -y

Step 4: Verify Python and pip

python3 --version
python3 -m pip --version

Step 5: Create and Activate a Virtual Environment:
create a virtual environment.

python3 -m venv myenv


Activate the environment.

source myenv/bin/activate

Step 6: Install Jupyter lab

pip install jupyterlab

Step 7: Launch Jupyter lab

  jupyter lab

Step 8: Access JupyterLab:

To access JupyterLab from outside the OCI instance, you need to open port 8888 (or the port you’re using) in your OCI security list.


Go to your OCI compute instance VCN and find the security list associated with it. Add an ingress rule to allow traffic on port 8888 (or the port you’re using)

Step 9: SSH Tunneling

To access the jupyter lab web browser, open another terminal and add the cmd:

ssh -i dev-instance-private.key opc@141.147.XX.XXX -L 8888:127.0.0.1:8888

The above cmd allows you to access the web browser of your jupyterlab running on the OCI compute instance in your local machine

After the above step, copy the given url on step 7 on your browser to access the notebook. ie.

http://localhost:8888/lab?token=8a4fe5599d5ec4565b0407a82161f2156a7f9acb6d331c4e

See also;

How to install a Jupyter notebook on a Mac book

Step 1: Install Homebrew if not already installed (Homebrew is a package manager for MacOS)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install Python

brew install python

Step 3: Verify Python installation

python3 --version

You should get something like this below:

Step 4: Install Jupyter Lab using pip command

pip install jupyterlab

Step 5: Verify installation

jupyter lab --version

Step 6: launch Jupyter Notebook

jupyter lab

Jupyter notebook launches on a webpage, on localhost port 8888 or 8889 based on available ports ie. http://localhost:8888/lab

more info- you can add the packages you require in the jupyter lab using pip command: ie Below packages are installed in the Jupiter lab

pip install oci pandas numpy matplotlib scikit-learn

Other cmds;

If you want to list the Jupyter lab sessions running:

juypter lab list

To close a session,close the terminal (ctrl+c) running the jupyter session or open another terminal and close the session using the below cmd

jupyter lab stop 8889

In my case above 8889 was my port number.