我正在尝试连接到 Oracle 数据库,但 python 脚本找不到 cx_Oracle。这是我的脚本:
import cx_Oracle
con = cx_Oracle.connect(‘DBNAME/testitout@www.xx.yy.zz:1521/yeppers’)
print(con.version)
con.close()
这是我得到的错误:
================= RESTART: C:\Python35\Connect_To_Oracle.py =================
Traceback (most recent call last):
File "C:\Python35\Connect_To_Oracle.py", line 1, in <module>
import cx_Oracle
cx_Oracle.DatabaseError: DPI-1047: Oracle Client library cannot be loaded: The specified module could not be found. See https://oracle.github.io/odpi/doc/installation.html for help
这是我的操作系统和版本信息:
- 英特尔至强 CPU E7-4870 @ 2.40GHz
- Windows Server 2008 R2 企业版
- Python 3.5
这是我安装 cx_Oracle 所做的:
1. Download Instant Client (Basic Client) from Oracle here : http://www.oracle.com/technetwork/topics/winx64soft-089540.html .
2. Unzip.
3. I added a new System Variable called ORACLE_HOME and pointed it to c:\Down\InstantClient , which is where I unzipped the above. This is what I downloaded: instantclient-basic-windows.x64-12.2.0.1.0
4. You have to download the whl file from here: https://pypi.python.org/pypi/cx_Oracle/ To do this, you need to know your version of Python and your type of processor.
5. You download into the scripts folder and then run pip install wheelfilename.whl
有人可以让我知道他们认为错误源于什么吗?
原文由 user8340926 发布,翻译遵循 CC BY-SA 4.0 许可协议
DPI-1047 错误中的说明 URL 显示将 PATH 设置为即时客户端库的位置。您还需要正确的 VS Redistributable - 全部在说明中给出。请注意,他们没有提到设置 ORACLE_HOME。
确保 Instant Client 与 Python 是相同的 32 位或 64 位架构。
cx_Oracle 安装说明位于 https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
在 Windows(和 macOS,但不是 Linux)上使用 cx_Oracle 8,您可以使用
init_oracle_client()
来说明 Instant Client 库的位置。这不是设置 PATH。