【问题标题】:Python cx_Oracle error "DPI-1047: Cannot locate a 32-bit Oracle Client"Python cx_Oracle 错误“DPI-1047:找不到 32 位 Oracle 客户端”
【发布时间】:2019-12-06 13:46:14
【问题描述】:

如何解决这个错误,我使用python3.6,我使用Oracle数据库11g,我想将我的python连接到oracle数据库,但是显示错误,我该如何解决?

这是我的代码:

#importing module
import cx_Oracle

#create a table in oracle database
try:
    con = cx_Oracle.connect('db_employees/root@localhost')

    #Now execute the sqlquery
    cursor = con.cursor()
    cursor.execute("insert into employees values(2171114103970002, raden, ceo, 01031997, batam, 001)")

    #commit that insert the provided database
    con.commit()
except cx_Oracle.DatabaseError as e:
    print("There is a problem with Oracle", e)

#by writing finally if any error occurs
#then also we can close the all database operation
finally:
    if cursor:
        cursor.close()
    if con:
        con.close()

这是消息错误:

C:\Python36>python "D:\testing.py"
There is a problem with Oracle DPI-1047: Cannot locate a 32-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help
Traceback (most recent call last):
  File "D:\testing.py", line 20, in <module>
    if cursor:
NameError: name 'cursor' is not defined

【问题讨论】:

  • 请检查您的代码格式。我已经编辑了您的帖子以使其格式清晰

标签: oracle oracle11g python-3.6 cx-oracle


【解决方案1】:

以下是安装说明:Installing cx_Oracle on Windows

错误是说您需要 32 位 Oracle 客户端库。您可以从32-bit Windows Instant Client 获得一个(如果有人需要,64 位库是here)任何版本高达 19c 都将连接到 Oracle DB 11.2。说明在页面的底部。确保您安装了正确的 VS 可再发行组件。

【讨论】:

  • 我已按照github上显示的步骤进行操作,但仍然没有工作,仍然有错误,我使用Python 3.6.5(32位)cx_Oracle 7.2.1 Windows 10(64位)
  • 这是我在 32 位和 64 位中安装的详细信息错误 github.com/oracle/python-cx_Oracle/issues/340
  • 谢谢克里斯托弗,第二个链接帮助了我。但第一个已损坏。
  • 我已经更新了它们 - 谢谢。 (如有疑问,请尝试 Google!)
【解决方案2】:

检查您的路径以查看客户端是否在上面,在某些情况下,路径未设置为指向客户端或包含无效字符,python 库无法访问它。

你可以在这里查看类似的问题https://github.com/oracle/python-cx_Oracle/issues/55

【讨论】:

    【解决方案3】:

    我遇到了同样的问题,这里是我解决这个问题的步骤 -

    1. 从以下位置下载最新的 64 位版本的 oracle basic instantClient: https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html

    就我而言,我已经下载了 - windows.x64-19.10.0.0.0dbru.zip

    1. 解压 Oracle InstantClient 并复制所有 .dll 文件

    2. 将这些 .dll 文件从 Oracle Instantclient 目录复制到 python 目录

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-23
      • 1970-01-01
      • 1970-01-01
      • 2019-10-09
      • 2022-11-07
      • 2019-01-06
      • 1970-01-01
      • 2013-03-22
      相关资源
      最近更新 更多