oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
308 stars 61 forks source link

init_oracle_client lib dir with chinese #255

Open 13033266796 opened 7 months ago

13033266796 commented 7 months ago
  1. What versions are you using?

platform.platform: Windows-10-10.0.17763-SP0 sys.maxsize > 2**32: True platform.python_version: 3.8.10

oracledb.version: 1.3.2

  1. Is it an error or a hang or a crash? oracledb.init_oracle_client(lib_dir="D:\哈哈哈哈哈哈哈哈哈哈或或\instantclient_11_2") Traceback (most recent call last): File "D:\Python38\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "src\oracledb\impl/thick/utils.pyx", line 458, in oracledb.thick_impl.init_oracle_client File "src\oracledb\impl/thick/utils.pyx", line 482, in oracledb.thick_impl.init_oracle_client File "src\oracledb\impl/thick/utils.pyx", line 403, in oracledb.thick_impl._raise_from_info oracledb.exceptions.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://python-oracledb.readthedocs.io/en//latest/user_guide/initialization.html#setting-the-oracle-client-library-directory for help

  2. What error(s) or behavior you are seeing?

init_oracle_client lib dir with chinese

How to solve the problem?

cjbj commented 7 months ago

Does it work if you use non-Chinese characters?

Does it work if you set the PATH environment variable (and call init_oracle_client() without any parameters)?

13033266796 commented 7 months ago

Does it work if you use non-Chinese characters? It work if use non-Chinese characters

Does it work if you set the PATH environment variable (and call init_oracle_client() without any parameters)? I try to set PATH: D:\111\instantclient_11_2 D:\哈哈哈哈哈哈哈哈哈哈或或\instantclient_11_2 None of them will take effect

cjbj commented 7 months ago

Can you set DPI_DEBUG_LEVEL to 64 (see the doc) and share the log?

13033266796 commented 7 months ago

Is it like this ?

((venv) D:\A_projects\dmp_tools>set DPI_DEBUG_LEVEL=64

(venv) D:\A_projects\dmp_tools>echo %DPI_DEBUG_LEVEL% 64

(venv) D:\A_projects\dmp_tools>python Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import oracledb oracledb.init_oracle_client(lib_dir=r"D:\哈哈哈哈哈哈哈哈哈哈哈哈哈合伙\instantclient_11_2") ODPI [15820] 2023-11-24 10:53:34.077: ODPI-C 5.0.1 ODPI [15820] 2023-11-24 10:53:34.078: debugging messages initialized at level 64 ODPI [15820] 2023-11-24 10:53:34.081: Context Parameters: ODPI [15820] 2023-11-24 10:53:34.082: Oracle Client Lib Dir: D:\?????????????????????????????????????????????\instantclient_11_2 ODPI [15820] 2023-11-24 10:53:34.085: Environment Variables: ODPI [15820] 2023-11-24 10:53:34.087: PATH => "D:\A_projects\dmp_tools\venv\Scripts;D:\111\instantclient_11_2;D:\Python310\Scripts\;D:\Python310\;D:\Python36\Scripts\;D:\Python36\;D:\Python38\Scripts\;D:\Python38\;D:\SecureCrt_FX\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;D:\Goang\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;D:\NodeJs\;C:\Users\User\AppData\Local\Microsoft\WindowsApps;;D:\PyCharm 2022.1\bin;;D:\DataGrip 2022.2.1\bin;;D:\GoLand 2022.2.1\bin;;C:\Users\User\go\bin;D:\Microsoft VS Code\bin;C:\Users\User\AppData\Roaming\npm" ODPI [15820] 2023-11-24 10:53:34.104: load in parameter directory ODPI [15820] 2023-11-24 10:53:34.105: load in dir D:\?????????????????????????????????????????????\instantclient_11_2 ODPI [15820] 2023-11-24 10:53:34.107: load with name D:\?????????????????????????????????????????????\instantclient_11_2/oci.dll ODPI [15820] 2023-11-24 10:53:34.111: load by OS failure: The specified module could not be found Traceback (most recent call last): File "", line 1, in File "src\oracledb\impl/thick/utils.pyx", line 476, in oracledb.thick_impl.init_oracle_client File "src\oracledb\impl/thick/utils.pyx", line 500, in oracledb.thick_impl.init_oracle_client File "src\oracledb\impl/thick/utils.pyx", line 421, in oracledb.thick_impl._raise_from_info oracledb.exceptions.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://python-oracledb.readthedocs.io/en/latest/user_guide/initialization.html for help

anthony-tuininga commented 1 month ago

Yes, that is what @cjbj meant. I took a quick peek at this. It seems that if you use LoadLibraryA(), even with a simple search name, that the underlying code is incapable of handling paths containing Chinese characters. Doing the same on Linux works as expected. Since this appears to be a Windows limitation it is not a bug in python-oracledb or ODPI-C itself. We may wish to document this limitation but it is unlikely that we can eliminate it. I am not a Windows expert, however, so if you have any suggestions I'd be happy to hear them!