1
votes

first question i really had to ask on stackoverflow! I'm trying to use cx_Oracle Python module to use SQL queries inside Google Colab. However, for cx_oracle to properly run I need Oracle instantclient installed - this is a problem as Colab works on VM. Without the client, I get error:

"DatabaseError: (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory"."

I tried to put oracle instantclient_18_5 unzipped folder into my GDrive where the Colab script is. After that, I've tried to change LD_LIBRARY_PATH to point to it, but no matter what I do, LD_LIBRARY_PATH directory is /usr/local/nvidia/lib:/usr/local/nvidia/lib64 .

!sudo apt-get install python-dev build-essential libaio1

!python -m pip install cx_Oracle --upgrade

''' I tried a lot of code found on the internet to change this LD_LIBRARY_PATH but to no avail. Example:'''

!export LD_LIBRARY_PATH="/content/gdrive/Team Drives/.../instantclient_18_5":$LD_LIBRARY_PATH

I would like either to install Oracle client onto google VM, or do something that it could take it from Gdrive. Whatever would work so I could use cx_oracle on Google Colab will be enough for me.

EDIT: To clarify, any way of connecting my Oracle SQL database to Google Colab python notebook will be fine! Does not have to be through cx_oracle exclusively.

1
I have the very same question. Anyone? - axiom

1 Answers

2
votes

Not an ideal solution, but a work-around, which is to install the official RPM via alien, then boom! cx_python works.

  1. Download the official Oracle Instant client basic lite RPM https://download.oracle.com/otn_software/linux/instantclient/193000/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm
  2. Put the RPM somewhere in Gdrive
  3. Mount the Gdrive

    from google.colab import drive ROOT = "/content/blah" drive.mount(ROOT)

  4. Install alien and cx_Oracle

    !pip install cx_Oracle #install Oracle client library !apt install alien !alien -i /content/blah/foo/bar/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm

hwala, it works for me