cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libaio.so.1

 

安装 centos7镜像里面安装cx_Oracle,运行报错

import cx_Oracle as oracle
dsnStr = oracle.makedsn('22.21.7.27', '11596', service_name='xe')
db = oracle.connect('test', 'test', dsn=dsnStr)

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libaio.so.1: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help

报错原因是没有安装instantclient 数据库客户端,这是oracle独有的,需要安装oracle-instantclient。

1.我的oracle 是生产版本19,测试版本12.1.0.2,我下载 oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm,根据自己的oracle和服务器选择版本

2. docker cp oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm    镜像id:/app

yum -y install ./oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm    #安装

sh -c "echo /usr/lib/oracle/12.1/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"       #软连接

ldconfig                             #ldconfig是一个动态链接库管理命令 为了让动态链接库为系统所共享,

 参考文档:https://www.shuzhiduo.com/A/gAJGYxl0dZ/

posted @ 2022-09-08 10:04  简单音乐  阅读(1081)  评论(0)    收藏  举报