Python 连接到 Oracle 数据库错误 DPI-1047

问题描述 投票:0回答:3

我尝试连接我的 Oracle 数据库,但出现错误。我是 python 的初学者,我尝试在文档中找到答案,但这对我来说很难。

Python version :
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32

Oracle version :
11.2.0.1.0

我的鳕鱼很简单:

    from sqlalchemy import create_engine
    import cx_Oracle
    
    
    engine =  create_engine('oracle://user:[email protected]:port/SID')
    result = engine.execute('select * FROM TABLE')

结果我得到一个错误:

    Exception has occurred: DatabaseError
    (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found".
python oracle cx-oracle
3个回答
3
投票

Python

cx_Oracle
库依赖于
Oracle Client library

从此处下载 Oracle 客户端库:https://www.oracle.com/database/technologies/instant-client.html

祝你好运!


1
投票

看起来库没有正确安装。 参考 cx_Oracle 错误。 DPI-1047:无法找到 64 位 Oracle 客户端库

安装cx_Oracle

python -m pip install cx_Oracle --upgrade

0
投票

正如 @Bjarte Brandt 答案中所述,您确实需要安装

Oracle Client library

对于现在(2024 年)发现此内容的任何人,

cx_Oracle
(如他们的文档中所述)“以新名称和主页有一个主要的新版本”,这个新版本可以通过
pip install oracledb
安装并使
Oracle Client libraries
成为可选,提供一种称为
Thin mode
的模式,其中不再需要安装库来执行简单查询(某些高级功能需要安装并使用
Thick mode
运行)。


免责声明:我本来想对此发表评论,但由于声誉低,我不被允许。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.