Jupyter Notebook连接远程Oracle数据库的系统配置

System configuration for Jupyter Notebook to connect to remote Oracle database

总结

我在桌面上配置 Oracle Install Client 时遇到困难,因此我无法将 Jupyter Notebook 连接到远程 Oracle 数据库。

我尝试过的事情

我尝试了来自 Stack Overflow 的几种调试解决方案、GitHub 错误报告、reading/re-reading/re-re-reading Windows 10 设置的 Oracle 文档、Youtube 视频、在线随机文章,以及我'我什至向公司周围的人寻求帮助。

我不认为这是我的代码,我认为我在桌面上错误地配置了 Oracle Instant Client。

我已确认我使用的是 64 位 Python、64 位 Windows,并安装了 64 位 Oracle 安装客户端。

我从这里下载了基本包和 SQL*Plus 包:https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html 然后我将这些包的各个内容提取到 C:/Oracle/instantclient_19_3 下载的软件包中没有 setup.exe 文件。

然后我创建了一个用户变量 -

变量:ORACLE_HOME

值:C:\Oracle\instantclient_19_3

并且我更新了 PATH 系统变量以包含环境变量: C:\Oracle\instantclient_19_3

(我也尝试过只使用 C:\Oracle 的值,但没有成功)

我的代码和产生的错误

import cx_Oracle

CONN_INFO = {
    'host': 'my-host',
    'port': my-port,
    'user': 'my-user',
    'psw': 'my-password',
    'service': 'my-service',
}

CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)

connection = cx_Oracle.connect(CONN_STR)
---------------------------------------------------------------------------
DatabaseError                             Traceback (most recent call last)
<ipython-input-4-f23d819d7d09> in <module>
     11 CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)
     12 
---> 13 connection = cx_Oracle.connect(CONN_STR)

DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help

想要的结果

我应该能够创建连接,没有错误,这样我就可以 运行 一个 SQL 查询。

设置 PATH 后重启终端、Jupyter 等。

仔细检查您确实获得了 64 位 Instant Client,而不是 32 位 Instant Client。

使用 Instant Client 时不要设置 ORACLE_HOME,因为这不是必需的。设置它对我来说是一个信号,表明您可能还有其他环境问题。