python - cx_Oracle.DatabaseError : DPI-1047: 64-bit Oracle Client library cannot be loaded: "dlopen(libclntsh.dylib, 1): image not found"

标签 python python-2.7 cx-oracle

我正在尝试设置 cx_Oracle 以使用 Python。

我正在使用

  • Python 2.7.10,64 位
  • cx_Oracle 版本 6.0.2
  • MacOS Sierra 10.12.6

我设置了以下环境变量:

export ORACLE_HOME="/Volumes/DATA/Programs/PY/instantclient_12_1"
export DYLD_LIBRARY_PATH="$ORACLE_HOME:$DYLD_LIBRARY_PATH"
export LD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME
export ORACLE_SID=edocd
export TNS_ADMIN=/Volumes/DATA/Programs/PY/instantclient_12_1/network/admin
export TWO_TASK=${ORACLE_SID}

这是我尝试过的:

  1. 以管理员身份安装
  2. sudo python setup.py build
  3. sudo python setup.py install

当我尝试执行一个简单的脚本来检查 Oracle 连接时,我能够通过 sqlplus 成功连接。

这是我收到的错误:

cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help

最佳答案

我的 Ubuntu 16.04(64 位)解决方案

official guidetl;dr: :

1) 下载instantclient-basic-linux.x64-12.2.0.1.0.zip

2) 解压到/opt/oracle目录:

$ sudo mkdir -p /opt/oracle
$ cd /opt/oracle
$ unzip ~/Downloads/instantclient-basic-linux.x64-12.2.0.1.0.zip

3) 安装libaio

$ sudo apt-get install libaio1

4) 像这样编辑 oracle-instantclient.conf 文件:

$ sudo sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf"
$ sudo ldconfig

关于python - cx_Oracle.DatabaseError : DPI-1047: 64-bit Oracle Client library cannot be loaded: "dlopen(libclntsh.dylib, 1): image not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46098562/

相关文章:

python - 在 Django 中保存文件之前更改文件名

python - 如何将 2 个列表的列表转换为 pandas 中的 2 列 df

PYTHONPATH 不适用于多个路径

python - python中的稀疏表示数据文件

python - Python 中的 cx_Oracle、生成器和线程

python - 将外部 python 函数作为 vim 命令运行

python - "Python"通过mroutes解析的方式是什么

Python 类不适用于排序函数

python-3.x - 如何在 Windows 中通过 LDAP 将 Python 3.x cx_Oracle 连接到 Oracle DB?

python - 使用 cx_Oracle 将变量绑定(bind)到表名