python - 使用cx_Oracle在python中连接oracle时出错

标签 python oracle cx-oracle

我正在尝试使用 python 连接 oracle 数据库,如下所示。

import cx_Oracle
conn = cx_Oracle.connect('user/password@host:port/database')

我在连接 oracle 时遇到错误。 DatabaseError:DPI-1047:无法加载 64 位 Oracle Client 库:“libclntsh.so:无法打开共享对象文件:没有这样的文件或目录”。参见 https://oracle.github.io/odpi/doc/installation.html#linux寻求帮助。

我一直在努力弄清楚。例如,我使用了我的用户名、密码、主机、端口和数据库('orcl'),

'admin/admin@10.10.10.10:1010/orcl'

为什么连接不上?

啊,顺便说一句,我正在 Azure 笔记本中运行所有代码。

最佳答案

该错误表明您缺少 64 位 Oracle 客户端安装或未正确配置。查看错误消息中提到的链接。它将提供有关如何执行 Oracle 客户端安装和配置的说明。

[代表 Anthony 更新:他最新的 cx_Oracle 版本不需要 Oracle Client 库,因此如果您升级,您将不会看到 DPI-1047 错误。驱动程序已重命名为 python-oracledb,但 API 仍支持 Python DB API 2.0 规范。查看homepage .]

关于python - 使用cx_Oracle在python中连接oracle时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47689456/

相关文章:

Python - 从子目录中找不到的目录文件中读取文件(在那里)

python - 从对象到字符串的 pandas dtype 转换

python - 如何从 Reddit 上的 subreddit 中抓取所有评论?

python - 刽子手 python 项目

python - 收到错误 cx_Oracle.DatabaseError : ORA-01008: not all variables bound while trying to bind the value of a list in a merge statement

Python - 类型错误 : expecting string or bytes object

sql - ALTER 语句 : Why VARCHAR2(50 BYTE) instead of VARCHAR2(50 CHAR)?

sql - PL/SQL : IF-ELSIF-ELSE -> ELSE block is not considered as a basic block

java - 如何在编译时使ojdbc特定代码数据库独立

python - cx_Oracle 插入大 XMLType 值