64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file报错

sudo运行python调用oracle报错问题解决

报错信息:

cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: “libclntsh.so: cannot open shared object file: No such file or directory”. See https://oracle.github.io/odpi/doc/installation.html#linux for help**

问题描述:

  • root用户下python ./*.py运行python程序import 了cx_Oracle模块连接oracle数据库,程序正常运行无报错。
  • root用户下sudo python运行python程序调用oracle数据库,出现上述错误。

解决方法:

#根据报错提供的文件libclntsh.so
vim /etc/ld.so.conf;
--------------------------------------
#末尾追加
/usr/lib/oracle/11.2/client64/lib #根据你安装oracle版本驱动路径
#保存运行
ldconfig;

此时在尝试sudo运行,或用crontab定时任务运行相关程序,无报错信息,问题解决。

猜你喜欢

转载自blog.csdn.net/weixin_43819222/article/details/87986531