簡體   English   中英

無法使用 Python cx_Oracle 設置與 Oracle 數據庫的連接

[英]Unable to setup connection to Oracle DB using Python cx_Oracle

我正在使用 M1 Mac 在 Python 3 中使用 cx_Oracle 連接到 Oracle DB。

import cx_Oracle
import os
import platform

dsn_tns = cx_Oracle.makedsn('host', 'port', service_name='tns_service_name')
conn = cx_Oracle.connect(user='user', password='pwd', dsn=dsn_tns)
cx_Oracle.init_oracle_client(lib_dir='/Users/user/Downloads/instantclient_19_8')

我已按照此處的說明安裝了 oracle 客戶端,但仍然無法連接並出現以下錯誤。

DatabaseError:DPI-1047:找不到 64 位 Oracle 客戶端庫:“dlopen(libclntsh.dylib,0x0001):已嘗試:'libclntsh.dylib'(沒有這樣的文件),'/usr/lib/libclntsh.dylib'(沒有這樣的文件),'/Users/balikuma/Desktop/libclntsh.dylib'(沒有這樣的文件)”。 請參閱https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html尋求幫助

為避免在 Apple M1 芯片上出現 Python 中的錯誤 DPI-1047,您可以升級 cx_Oracle。 最新的主要版本(取代 cx_Oracle 8.3)有一個新名稱python-oracledb 默認情況下,此新版本不需要 Oracle 客戶端庫。 檢查安裝文檔

還有適用於 macOS x86 和 M1 的通用二進制包,因此您無需編譯驅動程序或使用 Rosetta。 macOS 上存在 Python 3.8、3.9 和 3.10 的軟件包。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM