I installed JupyterHub using Docker container.
I created a new Anaconda Environment "cx_oracle_env", and installed package cx_Oracle in Terminal:
# Creates a new Anaconda Environment called "cx_oracle_env" using Python 3.7 in silent mode
conda create -n cx_oracle_env python=3.7 -y
# >>>> Returns no warnings / errors
# Activates the Anaconda Environment "cx_oracle_env"
conda activate cx_oracle_env
# >>>> Returns no warnings / errors
# Mamba is a reimplementation of the conda package manager in C++.
# - parallel downloading of repository data and package files using multi-threading
# - libsolv for much faster dependency solving, a state of the art library used in the
# RPM package manager of Red Hat, Fedora and OpenSUSE
# - core parts of mamba are implemented in C++ for maximum efficiency
# At the same time, mamba utilize the same command line parser, package installation and
# deinstallation code and transaction verification routines as conda to stay as compatible as
# possible.
#
conda install mamba -n base -c conda-forge -y
# >>>> Returns no warnings / errors
# Installs ipykernel in currently active Anaconda Environment
mamba install ipykernel -y
# >>>> Returns no warnings / errors
# Installs cx_Oracle
python -m pip install cx_Oracle --upgrade
# >>>> Returns no warnings / errors
# Binds ipykernel "cx_oracle_env" to Anaconda Environment "cx_oracle_env"
python -m ipykernel install --user --name cx_oracle_env --display-name="cx_oracle_env"
# >>>> Returns no warnings / errors
I downloaded the ORACLE InstantClient instantclient-basic-linux.x64-21.1.0.0.0.zip from https://www.oracle.com/uk/database/technologies/instant-client/linux-x86-64-downloads.html to my local computer, and uploaded the zip file to my JupyterHub working directory.
I opened a new Jupyter Notebook by selecting "cx_oracle_env" in section Notebook of the Launcher panel.
In Jupyter Notebook, I decompressed the file instantclient-basic-linux.x64-21.1.0.0.0.zip using following command:
from shutil import unpack_archive
# Decompress ZIP-file to working directory (/home/jovyan/instantclient_21_1/)
unpack_archive('instantclient-basic-linux.x64-21.1.0.0.0.zip', '')
>>>> Returns no warnings / errors
Check if path exists:
import os.path
from os import path
path.exists("/home/jovyan/instantclient_21_1")
# >>>> Returns True
Set LD_LIBRARY_PATH:
import os
os.environ["LD_LIBRARY_PATH"] = "/home/jovyan/instantclient_21_1"
!echo $LD_LIBRARY_PATH
# >>>> Returns /home/jovyan/instantclient_21_1
Set ORACLE_HOME:
os.environ["ORACLE_HOME"] = "/home/jovyan/instantclient_21_1"
!echo $ORACLE_HOME
# >>>> Returns /home/jovyan/instantclient_21_1
Install libaio:
!mamba install libaio -y
# >>>> Returns no warnings / errors
Import cx_Oracle:
import cx_Oracle
# >>>> Returns no warnings / errors
After Calling init_oracle_client, I get following error:
cx_Oracle.init_oracle_client(lib_dir=r"/home/jovyan/instantclient_21_1")
What am I missing?
PS: Unfortunately I don't have sudo permissions here in JupyterHub Terminal ...
I solved the problem finally by creating a new JupyterHub environment by customizing the Dockerfile from https://github.com/jupyter/docker-stacks/blob/master/minimal-notebook/Dockerfile, and embedded it as new "Minimal Oracle environment" in JupyterHub.
The custom Dockerfile has following content (I only added the "cx_Oracle installation begin/end" part):
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/base-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
USER root
# Install all OS dependencies for fully functional notebook server
RUN apt-get update && apt-get install -yq --no-install-recommends \
build-essential \
vim-tiny \
git \
inkscape \
libsm6 \
libxext-dev \
libxrender1 \
lmodern \
netcat \
# ---- nbconvert dependencies ----
texlive-xetex \
texlive-fonts-recommended \
texlive-plain-generic \
# ----
tzdata \
unzip \
nano-tiny \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# cx_Oracle installation begin
WORKDIR /opt/oracle
RUN apt-get update && apt-get install -y libaio1 wget
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \
unzip instantclient-basiclite-linuxx64.zip && rm -f instantclient-basiclite-linuxx64.zip && \
cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *README *jar uidrvci genezi adrci && \
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
RUN python -m pip install cx_Oracle
WORKDIR $HOME
# cx_Oracle installation end
# Create alternative for nano -> nano-tiny
RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10
# Switch back to jovyan to avoid accidental container runs as root
USER $NB_UID
After building the custom Dockerfile locally, and embedding it into the Kubernetes Cluster as "Minimal Oracle environment", I started a new Jupyter Notebook in the newly created JupyterHub environment, and tested the ORACLE connect as follows: