python - cx_Oracle 在可执行文件中不起作用,但在 IDE 中起作用
问题描述
我正在使用 Python 3.8.5 (Anaconda) 并尝试使用 oracle 即时客户端库 19_9 连接到数据库并使用 cx_Oracle 8.1 此命令:
cx_Oracle.init_oracle_client(lib_dir=path )
con = cx_Oracle.connect(db_connection_string)
给出以下错误:
cx_Oracle.DatabaseError: DPI-1072 Oracle client library version is unsupported
令人困惑的是,这根本不会发生在 IDE 中,而只会发生在可执行文件中。我正在使用 auto-py-to-exe 从 anaconda 提示符创建 exe。
谢谢您的帮助。
更新:
我得到:(其中 PATH 是我的客户端库路径)
load in dir PATH
load with name PATH\oci.dll
load by OS successful
validating loaded library
DPI-1072 Oracle client library version is unsupported
然后它再次尝试:
check module directory
module name is ...
load in dir PATH
load with name PATH\oci.dll
load by OS failure:The specified module could not be found
load with OS search heuristic
load with name oci.dll
load by OS failure: The specified module could not be found
Traceback ...
我使用的是 Windows 10 Pro,版本 20H2,OS build 19042.804(我不知道这是否有用)
解决方案
将环境变量设置DPI_DEBUG_LEVEL
为值 64 并查看 cx_Oracle 在这两种情况下尝试加载的内容。如果 Oracle 客户端库太旧(10g 或更早版本)或者该库可以加载但由于某种原因无法执行,则会发生该错误。例如,Windows 7 和 19c 客户端库会发生这种情况。
推荐阅读
- directory - Linux下的数据丢失
- amazon-web-services - 只让另一个微服务可以访问一个微服务
- css - Autoprefixer 在 gatsby 项目中做的很少
- javascript - 页面加载后如何使用javascript修改html
- angular - 当我在 FormBuilder 中设置字段时,为什么要在 DOM 中使用 `required`?
- java - 当我们声明一个向量时
> r,我们可以通过 r[0].insert(10) 轻松地将元素插入到集合中。同样,它是如何在java中完成的? - c++ - 如何逃脱 switch 和 while(1) 循环?
- python - Python:在同一个数据表上具有多个过滤器的仪表板
- for-loop - 由于不相关的表索引分配,Lua '尝试调用 for..in 附近的数字值' 错误 - 为什么?
- javascript - React setState 不会触发 Contexts 的重新渲染