8. JupyterHub Python Environment

Setup the environment as a kernel in JupyterHub

The following command should install the active conda environment as a kernel in your JupyterHub:

$ python -m ipykernel install --user --name=ocr

Connect to JupyterHub

Open a web browser and connect to any of the following to start up your JupyterHub:

In JupyterHub, you should see the new kernel show up under Notebook Launcher:

Test your process on JupyterHub

Try running your JupyterHub notebook using the conda kernel you just installed. You can change the kernel of an existing notebook by going to Kernel –> Change Kernel…:

Make sure you can import the required python packages in the notebook cell.

Copy and paste the following to test the import statements for python packages we will use:

import sys
import pandas as pd
from PIL import Image
import pytesseract   # OCR with Tesseract
import glob
import os, random
from matplotlib.pyplot import imshow
from mpl_toolkits.axes_grid1 import ImageGrid
import matplotlib.pyplot as plt
from tqdm import tqdm   

Kernel should indicate your conda environment name ocr:

In case you need to uninstall a kernel from Jupyter, use:

$ jupyter kernelspec list
$ jupyter kernelspec uninstall kernel-name

where kernel-name is the name of the kernel you want to uninstall.