How I got pyodbc and Oracle Instant Client working on Ubuntu

A guide of questionable universality

Photo by Michael Schofield on Unsplash

Prereqs

apt-get -y install unixodbc-dev

Get and install the Oracle Instant Client downloads

wget https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpmwget https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-instantclient-odbc-21.1.0.0.0-1.x86_64.rpmwget https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-instantclient-devel-21.1.0.0.0-1.x86_64.rpm
apt-get install -y alienalien -i oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm
alien -i oracle-instantclient-odbc-21.1.0.0.0-1.x86_64.rpm
alien -i oracle-instantclient-devel-21.1.0.0.0-1.x86_64.rpm
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/oracle/21/client64/lib"

Add an entry for the driver in odbcinst.ini

echo '' | tee -a /etc/odbcinst.iniecho '[MyOracle]' | tee -a /etc/odbcinst.iniecho 'Description=Oracle driver' | tee -a /etc/odbcinst.iniecho 'Driver=/usr/lib/oracle/21/client64/lib/libsqora.so.21.1' | tee -a /etc/odbcinst.iniecho 'UsageCount=1' | tee -a /etc/odbcinst.iniecho 'FileUsage=1' | tee -a /etc/odbcinst.ini
sudo tee -a /etc/systemd/system/task_id_mgr.service > /dev/null <<EOT
[MyOracle]
Description=Oracle Unicode driver
Driver=/usr/lib/oracle/21/client64/lib/libsqora.so.21.1
UsageCount=1
FileUsage=1
EOT

Did you get an error?!

[unixODBC][Driver Manager]Can't open lib '/usr/lib/oracle/21/client64/lib/libsqora.so.21.1' : file not found...
ldd /usr/lib/oracle/21/client64/lib/libsqora.so.21.1
apt-get install libaio1 libaio-dev

Parting thoughts

John is a software engineer who primarily works in data science platform design.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store