docker run error : DPI-1047: Cannot locate a 64-bit Oracle Client library
docker run error : DPI-1047: Cannot locate a 64-bit Oracle Client library
我正在尝试将一个非常简单的 python 应用程序与 Oracle 数据库连接并在 Docker 上执行它。此应用程序在我的本地计算机上运行良好。
我能够成功构建此应用程序,但在 Docker 上执行时出现错误。
Docker文件:
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 应用程序与 Oracle 数据库连接并在 Docker 上执行它。此应用程序在我的本地计算机上运行良好。
我能够成功构建此应用程序,但在 Docker 上执行时出现错误。
Docker文件:
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 发行版,步骤可能会有所不同。