error when connecting oracle in python using cx_Oracle

こ雲淡風輕ζ 提交于 2019-12-10 21:41:52

问题


I was trying to connect oracle database using python like below.

import cx_Oracle
conn = cx_Oracle.connect('user/password@host:port/database')

I've faced an error when connecting 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.

I've been struggling to figure it out. I used my user name, password, host, port and database('orcl') for example,

'admin/admin@10.10.10.10:1010/orcl'.

Why coudn't it connect?

Ahh, btw I'm running all the code in azure notebooks.


回答1:


That error indicates that you are missing a 64-bit Oracle client installation or it hasn't been configured correctly. Take a look at the link mentioned in the error message. It will give instructions on how to perform the Oracle client installation and configuration.




回答2:


This seems a problem with version 6.X.This problem didnot appeared in 5.X.But for my case a little workaround worked.I installed in my physical machine and only thing that i need to do was a pc reboot or reopen the terminal as i have added in the path of environment variables.You can try to install in physical machine instead using azure notebooks.




回答3:


This error come when your Oracle Client is not installed or LD_LIBRARY_PATH is not set where libclntsh.so is present.

if you have Oracle client installed then search for libclntsh.so and set the LD_LIBRARY_PATH as

"export LD_LIBRARY_PATH=/app/bds/parcels/ORACLE_INSTANT_CLIENT/instantclient_11_2:$LD_LIBRARY_PATH"



来源:https://stackoverflow.com/questions/47689456/error-when-connecting-oracle-in-python-using-cx-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!