【发布时间】:2017-10-03 07:39:33
【问题描述】:
我在我的 python 脚本中使用 cx_Oracle 库。如果我直接从 Linux 终端通过 python 脚本执行,我的代码可以正常工作,但是当我把它放在 crontab 中时,我得到了以下错误。
!!DatabaseError: DPI-1047: Oracle Client library cannot be loaded: libclntsh.so: cannot open shared object file: 没有这样的文件或目录。请参阅https://oracle.github.io/odpi/doc/installation.html 寻求帮助
DPI-1005:无法获取 Oracle 环境句柄 !!回溯(最近一次通话最后): 导入 cx_Oracle !!DatabaseError: DPI-1005: 无法获取 Oracle 环境句柄
我用谷歌搜索了这个问题,使用 crontab 运行时似乎缺少一些环境变量。 我尝试在 crontab 中导出以下内容,但它不起作用。
导出 LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client64/lib'
如果我删除 cx_Oracle 包,其他代码运行良好。我的机器上只安装了一个版本的 python。
您的 Python 版本是多少?它是 32 位还是 64 位? 蟒蛇 2.6 。 64位
您的 cx_Oracle 版本是多少? 版本 6.0b1
您的 Oracle 客户端版本是什么(例如 Instant Client)?它曾是怎样的 安装?它安装在哪里? oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
您的操作系统和版本是什么? CentOS 6.7
你设置了什么环境变量?你究竟是如何设置它们的? export LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client64/lib'
【问题讨论】:
标签: oracle environment-variables crontab cx-oracle