gpt4 book ai didi

python-3.x - docker 运行错误:DPI-1047:无法找到64位Oracle客户端库

转载 作者:行者123 更新时间:2023-12-02 19:51:47 25 4
gpt4 key购买 nike

我正在尝试使用Oracle数据库连接对一个非常简单的python应用程序进行docker化,并在Docker上执行它。该应用程序在我的本地计算机上运行良好。
我能够成功构建此应用程序,但在Docker上执行该应用程序时出现错误。
DockerFile:

FROM python:3

ADD File.py /

RUN pip install cx_Oracle
RUN pip install pandas
RUN pip install openpyxl

CMD [ "python", "./File.py" ]
File.py:
import cx_Oracle
import pandas as pd

#creating database connection
dsn_tns = cx_Oracle.makedsn('dev-tr01.com', '1222', service_name='ast041.com')
conn = cx_Oracle.connect(user=r'usr', password='3451', dsn=dsn_tns)
c = conn.cursor()

query ='SELECT * FROM Employee WHERE ROWNUM <10'
result = pd.read_sql(query, con=conn)
result.to_excel("batchtable.xlsx")

conn.close()
错误:

docker run python_batchdriver:latest

cx_Oracle.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://oracle.github.io/odpi/doc/installation.html#linux for help

最佳答案

对于cx_Oracle,您还需要安装Oracle Instant Client库。参见cx_Oracle installation instructions

有多种方法可以自动在Docker中进行安装。一个例子是:

RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \
unzip instantclient-basiclite-linuxx64.zip && \
rm -f instantclient-basiclite-linuxx64.zip && \
cd instantclient* && \
rm -f *jdbc* *occi* *mysql* *jar uidrvci genezi adrci && \
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && \
ldconfig

您还将需要libaio或libaio1软件包。

参见 Docker for Oracle Database Applications in Node.js and Python

另请参阅 Install Oracle Instant client into Docker container for Python cx_Oracle
请注意,如果您未使用基于Debian的Linux发行版,则步骤可能会有所不同。

关于python-3.x - docker 运行错误:DPI-1047:无法找到64位Oracle客户端库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60149492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com