개발/Python

[오라클/파이썬] DPI-1047오류 해결방법(oracledb)

호이호이209 2022. 10. 12. 18:38
728x90

환경 Ubuntu 20.04.4 LTS

해당글은 "cx_Oracle error. DPI-1047: Cannot locate a 64-bit Oracle Client library" 오류가 아닙니다.

"oracledb.exceptions.DatabaseError: DPI-1047:" 오류 입니다. 하지만 해결 방법은 같습니다.

발생 오류

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

 

해결방법

1) 환경에 맞는  클라이언트 다운로드 (저는 wget을 사용하기 위해, 링크복사를 했습니다.) https://www.oracle.com/kr/database/technologies/instant-client/downloads.html

2) 오라클 폴더 생성 및 환경설정

sudo mkdir -p /opt/oracle
cd /opt/oracle/

wget https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip
unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip

sudo apt-get install -y libaio1

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

 

참고

https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html#oracle-instant-client-zip-files

728x90