[英]cx_Oracle error. DPI-1047: Cannot locate a 64-bit Oracle Client library
[英]cx_Oracle connection fails with 'DPI-1047: Cannot locate a 64-bit Oracle Client library'
問題使用連接 oracle 到 python 源,oracle 現在可以使用其他語言 ZE1BFD762321E4109CEE4AC0B6E
錯誤:
Traceback (most recent call last):
File "c:\xampp\htdocs\pyoracle\testConnectionOracle.py", line 4, in <module>
conn = cx_Oracle.connect('xxx','xxx', dsn_tns,'UTF-8')
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "failed to get message for Windows Error 126". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
代碼:
import cx_Oracle
dsn_tns = cx_Oracle.makedsn('192.168.1.217', '1521', service_name='xx')
conn = cx_Oracle.connect('xx','xx', dsn_tns,'UTF-8')
c = conn.cursor()
c.execute('select * from database.table')
for row in c:
print (row[0], '-', row[1])
conn.close()
這是cx_Oracle Windows 安裝說明,您可能從您引用的錯誤消息中找到。
我將假設 (i) 您實際上擁有 11g 或更高版本的 64 位 Oracle 客戶端庫,並且 (ii) 具有安裝說明中提到的所需的 VS Redistributable。 然后一個簡單的嘗試是將其添加到腳本的頂部:
cx_Oracle.init_oracle_client(lib_dir=r"C:\oracle\instantclient_19_6")
使用客戶端庫的實際路徑。
PHP 可能是 32 位並使用 32 位 Oracle 庫。 如果是這樣,因為您有 64 位 Python,那么您將需要安裝 64 位 Instant Client 或安裝 32 位 Python。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.