如何修复:cx_Oracle.DatabaseError:DPI-1047:无法找到64位Oracle客户端库-Python [英] How to fix: cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library - Python

查看:439
本文介绍了如何修复:cx_Oracle.DatabaseError:DPI-1047:无法找到64位Oracle客户端库-Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cx_oracle 7和python 3.6.7建立到远程服务器中oracle 11g的连接。我在Ubuntu 18.04中的操作系统

I am establishing a connection to oracle 11g which is in a remote server using cx_oracle 7 with python 3.6.7. my OS in Ubuntu 18.04

我已经用libclntsh.so安装了Oracle Instant Client库,但没有得到预期的输出。

I have installed oracle instant client library with libclntsh.so but I am not getting the expected output.

这是我用来连接到Oracle数据库的代码

here is the code which i am using to connect to the oracle db

connection = cx_Oracle.connect("username/password@host/port")
print (connection.version)
connection.close()

当脚本运行时,我希望获得连接版本,而不是得到以下错误消息

when the script runs i expect to get the connection version instead i am getting the following error message


文件 script.py,第13行,在
连接= cx_Oracle.connect(用户名/密码@主机/端口)cx_Oracle.DatabaseError:DPI-1047:无法找到64位Oracle
客户端库: libclntsh.so:无法打开共享对象文件:没有这样的
文件或目录。参见
https://oracle.github.io/odpi/doc/ installation.html#linux 获得帮助


推荐答案

经过更多研究后,我得到了来自 ubunu社区的解决方案,在安装oracle Instantclient之后,您将必须进行集成oracle库如下:

After some more research i got the solution from ubunu community , after you have installed oracle instantclient you will have to integrate oracle libraries as follows:


export
LD_LIBRARY_PATH = / usr / lib / oracle / < version> ; / client(64)/ lib / $ {LD_LIBRARY_PATH:+:$ LD_LIBRARY_PATH}

export LD_LIBRARY_PATH=/usr/lib/oracle/<version>/client(64)/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

例如,用于Linux x86_64的12.1版本:

For example, 12.1 version for Linux x86_64:

导出
LD_LIBRARY_PATH = / usr / lib / oracle / 12.1 / client64 / lib / $ {LD_LIBRARY_PATH:+:$ LD_LIBRARY_PATH}

export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

其中< version> 表示您的Oracle intantclient版本,例如11.2、12.2

连接参数应如下所示: connection = cx_Oracle.connect(用户名/密码@主机/服务名,例如orcl)

where <version> indicates the version of your of your oracle intantclient e.g 11.2, 12.2
The connection parameter should be as follows connection = cx_Oracle.connect("username/password@host/service_name e.g orcl")

要获取侦听器/服务名称,请在oracle sqlplus中键入以下内容

to get the listener/service_name type the following in the oracle sqlplus

SQL> show parameter local_listener

该值为侦听器

这篇关于如何修复:cx_Oracle.DatabaseError:DPI-1047:无法找到64位Oracle客户端库-Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆