0

I encounter DatabaseError: Error while trying to retrieve text for error ORA-01804 when I try to connect python to oracle. I have downloaded instant client 19.3.0.0.0

I am using MacBook(10.15.3). Here is my code:

! pip install cx_Oracle

import io
import base64
from urllib.request import urlopen

import os
os.chdir("/Users/aa/Option/Oracle/instantclient_19_3-2") # use the path we copied from step 5
import cx_Oracle

dsn_tns = cx_Oracle.makedsn("aaa", "bbb", service_name="ccc")
conn = cx_Oracle.connect(user= "ddd", password="222", dsn=dsn_tns)
c = conn.cursor()

it returns:

Requirement already satisfied: cx_Oracle in /Users/aa/opt/anaconda3/lib/python3.7/site-packages (7.3.0)
---------------------------------------------------------------------------
DatabaseError                             Traceback (most recent call last)
<ipython-input-17-d2cb8e0df445> in <module>
     10 
     11 dsn_tns = cx_Oracle.makedsn("aaa", "bbb", service_name="ccc")
---> 12 conn = cx_Oracle.connect(user= "ddd", password="222", dsn=dsn_tns)
     13 c = conn.cursor()

DatabaseError: Error while trying to retrieve text for error ORA-01804

How can I solve it? Thank you very much.

  • Read the [cx_Oracle installation instructions](https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html) - there is no `chdir()` mentioned. Review current [github issues](https://github.com/oracle/python-cx_Oracle/issues) for cx_Oracle on macOS regarding notarization and about Catalina. – Christopher Jones May 17 '20 at 11:11

1 Answers1

1

Make sure that your ORACLE_HOME and LD_LIBRARY_PATH environment variables are correctly set (or unset) before you run your script.

pmdba
  • 6,457
  • 2
  • 6
  • 16