gpt4 book ai didi

python - 使用 cx_oracle 连接到 Oracle 数据库在 Windows 上出现 DPI-1047

转载 作者:太空宇宙 更新时间:2023-11-04 04:47:04 24 4
gpt4 key购买 nike

import pandas as pd
import sqlalchemy

engine = sqlalchemy.create_engine('oracle://XXX:XXX@XXX:XXX/?service_name=XXX')

sql = 'select * from XXX where rownum < 10'
df = pd.read_sql(sql,con=engine)

DatabaseError: (cx_Oracle.DatabaseError) DPI-1047: 64-bit Oracle Client library cannot be loaded: "C:\oracle\11.2.0\bin\oci.dll is not the correct architecture". See https://oracle.github.io/odpi/doc/installation.html#windows for help

我正在尝试使用 Python 连接到 Oracle 数据库,但收到上述错误。我知道:

  1. 我已经设置了查看正确位置的路径 - 它显示在错误中。
  2. Python 是 64 位的。
  3. bin 文件夹位置包含一个 32 位 (ociw32.dll) 和一个 64 位 (oci.dll) 文件。

但是错误仍然告诉我架构是错误的。

在这方面的任何帮助都会很棒 - 我无法弄清楚问题可能出在哪里!

最佳答案

错误消息中提到的文件是 32 位 DLL,而不是 64 位 DLL——至少假设检查此类内容的逻辑是正确的!该代码使用此处提到的 imagehelp API:How can I test a Windows DLL file to determine if it is 32 bit or 64 bit? .还有一些其他方法可以验证 DLL 是 32 位还是 64 位。检查您的 PATH 并确保 64 位 Oracle Client 安装位于 PATH 中的第一个。下载并解压缩 64 位 Oracle Instant Client,以便快速轻松地进行测试。

关于python - 使用 cx_oracle 连接到 Oracle 数据库在 Windows 上出现 DPI-1047,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49322210/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com