【发布时间】:2021-06-09 14:56:41
【问题描述】:
我使用 Docker 容器安装了 JupyterHub。
-
我创建了一个新的 Anaconda 环境“cx_oracle_env”,并在终端中安装了包 cx_Oracle:
# Creates a new Anaconda Environment called "cx_oracle_env" using Python 3.7 in silent mode conda create -n cx_oracle_env python=3.7 -y # >>>> Returns no warnings / errors # Activates the Anaconda Environment "cx_oracle_env" conda activate cx_oracle_env # >>>> Returns no warnings / errors # Mamba is a reimplementation of the conda package manager in C++. # - parallel downloading of repository data and package files using multi-threading # - libsolv for much faster dependency solving, a state of the art library used in the # RPM package manager of Red Hat, Fedora and OpenSUSE # - core parts of mamba are implemented in C++ for maximum efficiency # At the same time, mamba utilize the same command line parser, package installation and # deinstallation code and transaction verification routines as conda to stay as compatible as # possible. # conda install mamba -n base -c conda-forge -y # >>>> Returns no warnings / errors # Installs ipykernel in currently active Anaconda Environment mamba install ipykernel -y # >>>> Returns no warnings / errors # Installs cx_Oracle python -m pip install cx_Oracle --upgrade # >>>> Returns no warnings / errors # Binds ipykernel "cx_oracle_env" to Anaconda Environment "cx_oracle_env" python -m ipykernel install --user --name cx_oracle_env --display-name="cx_oracle_env" # >>>> Returns no warnings / errors -
我从https://www.oracle.com/uk/database/technologies/instant-client/linux-x86-64-downloads.html 下载了 ORACLE InstantClient instantclient-basic-linux.x64-21.1.0.0.0.zip 到我的本地计算机,并将 zip 文件上传到我的 JupyterHub 工作目录。
-
我通过在 Launcher 面板的 Notebook 部分中选择“cx_oracle_env”打开了一个新的 Jupyter Notebook。
-
在 Jupyter Notebook 中,我使用以下命令解压了 Instantclient-basic-linux.x64-21.1.0.0.0.zip 文件:
from shutil import unpack_archive # Decompress ZIP-file to working directory (/home/jovyan/instantclient_21_1/) unpack_archive('instantclient-basic-linux.x64-21.1.0.0.0.zip', '') >>>> Returns no warnings / errors -
检查路径是否存在:
import os.path from os import path path.exists("/home/jovyan/instantclient_21_1") # >>>> Returns True -
设置 LD_LIBRARY_PATH:
import os os.environ["LD_LIBRARY_PATH"] = "/home/jovyan/instantclient_21_1" !echo $LD_LIBRARY_PATH # >>>> Returns /home/jovyan/instantclient_21_1 -
设置 ORACLE_HOME:
os.environ["ORACLE_HOME"] = "/home/jovyan/instantclient_21_1" !echo $ORACLE_HOME # >>>> Returns /home/jovyan/instantclient_21_1 -
安装 libaio:
!mamba install libaio -y # >>>> Returns no warnings / errors -
导入 cx_Oracle:
import cx_Oracle # >>>> Returns no warnings / errors -
调用 init_oracle_client 后,出现以下错误:
cx_Oracle.init_oracle_client(lib_dir=r"/home/jovyan/instantclient_21_1")
我错过了什么?
【问题讨论】:
标签: python oracle cx-oracle jupyterhub instantclient