LoginSignup
2
0

More than 1 year has passed since last update.

[python] [cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library] が起きた時の対処法3選

Last updated at Posted at 2021-10-14
cx_Oracle.DatabaseError: 
DPI-1047: Cannot locate a 64-bit Oracle Client library: 
"The specified module could not be found".
 See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
  • エラー解決法

    1. Oracle Instant Clientをダウンロードしてない
    2. Oracle Instant Clientのpathを正しく通せてない
    3. それでも解決できないとき...
  • Oracle Instant Clientをダウンロードしてない

    cx_Oracleを使う場合にダウンロードが必要です。
    windowsはこちらから(64bit)

  • Oracle Instant Clientのpathを正しく通せてない

    pathを設定する必要がある

    1. 環境変数の編集から設定する方法 (2のほうが簡単かも)
      左下のwindowsキーを押して検索から「環境変数」と入力 環境変数を編集を選び、ユーザーの環境変数のPathから 新規でinstantclient_19_121までのpathを設定
      (例: C:\Users\ユーザー名\hoge\instantclient_19_12 など)
    2. コードでpathをかく方法
      cx_Oracle.init_oracle_client()を使ってpathを設定できる
import cx_Oracle

lib_dir = "自分のPC内のinstantclientまでのpath"
cx_Oracle.init_oracle_client(lib_dir=lib_dir)

# フォルダーまでのpath
# pathの最初にrを付けること つけないとSyntaxErrorがでる
# (例 : r"C:\Users\ユーザー名\hoge\instantclient_19_12" )
  • それでも解決できないとき...

    自分はこの場合でしたが、デスクトップにあったinstantclient_19_12のフォルダーを
    別の場所(Downloadsなど)に変えてからpathを設定すると動きました
    原因はわからないです...

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0