代码之家  ›  专栏  ›  技术社区  ›  Pedro Martins de Souza Regeesh Chandran

Python和Oracle DB-“Error DPI-1050:Oracle客户端库必须是11.2或更高版本”

  •  0
  • Pedro Martins de Souza Regeesh Chandran  · 技术社区  · 6 年前

    几天前,我被要求开发一个能够连接到oracledb的Python应用程序。因为我已经安装了Oracle客户端(12.2.0版),所以我只是pip安装了cx\ U Oracle,并尝试使用以下代码建立连接:

    import pandas as pd
    import cx_Oracle
    
    connection = cx_Oracle.connect('username/password@service_as_described_in_tnsnames.ora')
    cur=connection.cursor()
    
    input("Press Enter to continue...")
    
    cur.execute('select* from MY_PRETTY_TABLE')
    for line in cur:
        print()
    
    cur.close()
    connection.close()
    

    但是当我试着运行它的时候,我得到了一个错误“ DPI-1050:Oracle客户端库必须为11.2或更高版本 ". 在谷歌上搜索之后,我发现 this 回答,并尝试将我的代码更改为:

    my_dsn = cx_Oracle.makedsn("host",port,sid="sid")
    connection = cx_Oracle.connect(user="user", password="password", dsn=my_dsn)
    cursor = connection.cursor()
    
    querystring = "SQL query"
    cursor.execute(querystring)
    

    此外,如果有帮助,我的路径设置为:

    C:\instantclient_12_1
    C:\Users\oracle2\product\12.1.0\client_1
    C:\Users\oracle2\product\12.1.0\client_1\bin
    C:\Users\oracle\product\12.2.0\dbhome_1\bin
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   Anthony Tuininga    6 年前

    这个错误意味着你 另一个

        2
  •  0
  •   Mazin Ibrahim    5 年前

    我卸载了它,并安装了以前版本的Oracle Instant client 12.2.0.1.0到,它运行正常。 https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html

    在尝试上述方法之前要做的重要事情:

    c:> where oci.dll 
    

    确保只找到一个条目并删除多余的条目。