Jupyter - DrAlzahraniProjects/csusb_fall2024_cse6550_team2 GitHub Wiki

  1. Installation
  2. Configuration
  3. Implementation
  4. Usage
  5. Troubleshooting

Installation

Prerequisites

  • Make sure Python is version 3.7 or later by using this comand
python --version
  • Make sure that pip is up to date using this command
python -m pip install --upgrade pip

1. Add Jupyter as a requirement in requirement.txt so it installs along with the other required Python packages

requirement.txt screenshot

Image 1: Jupyter added to requirements.txt

2. Check if Docker is installed

Before adding jupyter to the docker, make sure docker is installed by using the following command in the terminal:

docker --version

If it is not installed, you should go to the Docker wiki page and follow the instillation steps

3. Copy requirement to docker

copy requirement screenshot

Image 2: Copy requirements.txt to Docker

This should copy the requirements.txt into /app/requirements.txt, from where the required packages will be downloaded

4. Install Jupyter notebook

Make sure that the python version is at least 3.6 and you can go here to make sure its up to date. When on the required version you can use the following command in the terminal to install jupyter

    pip install jupyter 

When it is installed, we can use the lines in the image below to install Jupyter directly into the Dockerfile

Install Jupyter notebook screenshot

Image 3: Install Jupyter notebook

5. Check if jupyter is installed

Type the following command into the terminal to make sure that it's properly installed

    jupyter --version

6. Open Jypyter notebook

Using this url we are able to open the notebook

Configuration

1. Use this command in the terminal to configure the notebook

    jupyter notebook --generate-config

2. The image below shows how the notebook’s configuration is set by creating a directory with all the configuration

Jupyter notebook configuration screenshot

Image 4: Configure notebook

###3. You should be able to access the notebook by using this command in the terminal

    jupyter notebook

Or you can go to this url

The note book should look like the image below

screenshot of Jupyter Notebook

Image 5: Jupyter Notebook

Implementation

This makes sure that jupyter is implemented

Jupyter notebook implementation screenshot

Image 6: Jupyter notebook implementation

Use the flowing command to open Jupyter notebook with docker on port 6002. This allows you to open the notebook through localhost

docker run -p 6002:6002 team2-app

Usage

The command below allows us to run jupyter notebook on port 6002 through the docker

Jupyter Notebook port screenshot

Image 7: Change jupyter port

Using Markdown and Python, we can create the following

juputer notebook example screenshot

Image 8: Juputer notebook example

by writing the text in image 9 into mark down

markdown code screenshot

Image 9: Markdown text

Markdown allows us to write well-formatted notes using this format

    # for titles
    ## for major headings
    ### for subheadings
    - for bullet points

Jupyter allows us to use python normally alongside the markdowns so we can describe every segment of code in detail

python in Jupyter notebook screenshot

Image 10: Python in jupyter notebook

Using the steps above we documented our code into jupyter notebook Final Jupyter notebook

Image 11: Jupyter Notebook with Markdown, Python code cell, and the output of the code cell

Visit the Jupyter Notebook Documentation for more details on how we documented the code.

Troubleshooting

1. Jupyter notebook not opening

If you are unable to open Jupyter Notebook in the browser, make sure that port 6002 is properly mapped to Docker. You can also use this command to check for port conflicts

    docker run -p 82:82 -p 5002:5002 -p 6002:6002 team2-app

2. Increase Docker Resources

Increase Docker container resource limits to ensure sufficient resources are allocated by using the command below

    docker run -m 4g --cpus="2" -p 6002:6002 your_image_name

3. Other Errors

If there are any errors installing packages, make sure the requirement.txt file is correctly specified and check the version specified is comparable to avoid dependency conflicts

4. Debugging Tip

Used to check Jupyter logs

jupyter notebook --debug
⚠️ **GitHub.com Fallback** ⚠️