Linux and Oracle Instant Client

JupyterHub Oracle InstantClient and cx_Oracle installation

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:

Sample Image

oracle instant client zip file installation on linux

Just follow the install instructions http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html#ic_x64_inst

How to identify Oracle Instant Client in a Django project?

  • It seems that you might have multiple versions of Oracle libraries installed. As you found, you need to make sure that a 64-bit set of Oracle Client libraries is available to Python. Or alternatively use a 32-bit Python executable.

  • If you already have the libraries installed on this machine (since you say you can use cx_Oracle directly), then in your Django settings.py file add a call to cx_Oracle.init_oracle_client(lib_dir=r"\path\to\instantclient"). (This technique also works on macOS, but not Linux)

  • Alternatively, use the new major version of cx_Oracle - which got renamed to python-oracledb, see the release announcement. It doesn't need Oracle Client libraries. See this post.



Related Topics



Leave a reply



Submit