【发布时间】:2022-01-18 00:08:22
【问题描述】:
在我的本地机器上
我在 python 中创建了一个从 Oracle 数据库检索数据的脚本。 使用 cx_Oracle 完成与数据库的连接:
con = cx_Oracle.connect (username, password, dbService)
使用 SQL developer 时,连接是使用 自定义 JDBC 建立的。
在 Linux 服务器上复制过程。
- 我创建了一个安装了 cx-Oracle pip 的 python 虚拟环境。
- 我在服务器上安装了Oracle Client 19.3.0,instantclient文件夹就位。
当我尝试按原样执行 python 脚本时,出现以下错误。
cx_Oracle.DatabaseError: DPI-1047: 找不到 64 位 Oracle 客户端库: DPI-1047:找不到 64 位 Oracle 客户端库:“libclntsh.so:无法打开共享对象文件:没有这样的文件或目录”。请参阅https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html 寻求帮助
我认为问题出在 Oracle 路径上,这不是 python 所期望的。因此,我添加了这行额外的代码,以精确定位 Oracle 库所在的路径。
cx_Oracle.init_oracle_client(lib_dir=r"/apps/oracle/product/19.3.0/lib")
这会导致另一个错误:
cx_Oracle.DatabaseError:尝试检索错误文本时出错 ORA-01804
有什么线索吗?
【问题讨论】:
标签: python linux oracle cx-oracle