Error when trying to install cx_Oracle library on a standard access mode compute

Create an init script to install the library in a custom location outside of '/databricks/*`.

Written by saikumar.divvela

Last published at: September 8th, 2025

Problem

When you try to install the cx_Oracle library and connect to an Oracle database on a standard access mode (formerly shared access mode) compute, you receive the following error.

Error while fetching data DPI-1047: Cannot locate a 64-bit Oracle Client library: "/databricks/driver/instantclient_19_10/lib/libclntsh.so: cannot open shared object file: Permission denied". 

 

Cause

The cx_Oracle library depends on the Oracle Instant Client, which must be installed along with its dependencies at the OS level. The Oracle Instant Client files are typically installed under /databricks/driver/ using an init script. 

 

Working on a standard access mode compute raises a permissions issue. Since the init script runs before the driver process starts, the installation succeeds. However, the driver startup process locks down the directory, preventing cx_Oracle from connecting to Oracle.

 

Specifically: 

  1. When the driver starts, Databricks automatically enforces strict file system permissions on /databricks/* and related directories on the standard access mode compute.
  2. As part of this enforcement, non-root access to /databricks/driver/ is removed.
  3. Because of this removal, cx_Oracle cannot read the client libraries located in /databricks/driver/instantclient_19_10/lib/ and fails with the permission denied error.

 

Solution

Create an init script on your standard access mode compute that installs the cx_Oracle library in a custom directory outside of /databricks/*

 

You can adapt the following example script. It makes a directory called /oracle_ctl and installs the Oracle Instant Client in this directory.

#!/bin/bash
mkdir /oracle_ctl
sudo apt-get install libaio1 -y
wget --quiet -O /tmp/instantclient-basic-linux.arm64-19.10.0.0.0dbru-2.zip https://download.oracle.com/otn_software/linux/instantclient/191000/instantclient-basic-linux.arm64-19.10.0.0.0dbru-2.zip
unzip /tmp/instantclient-basic-linux.arm64-19.10.0.0.0dbru-2.zip -d /oracle_ctl/
sudo echo 'export LD_LIBRARY_PATH="/oracle_ctl/instantclient_19_10:$LD_LIBRARY_PATH:$LD_LIBRARY_PATH"' >> /databricks/spark/conf/spark-env.sh
sudo echo 'export ORACLE_HOME="/oracle_ctl/instantclient_19_10"' >> /databricks/spark/conf/spark-env.sh
sudo sh -c "echo /oracle_ctl/instantclient_19_10 > /etc/ld.so.conf.d/oracle-instantclient.conf"
export PATH=/oracle_ctl/instantclient_19_10:$PATH
sudo ldconfig

 

Then verify the Oracle Instant Client installation. Ensure the libclntsh.so file is accessible and the environment variables LD_LIBRARY_PATH and ORACLE_HOME are correctly set.