Ubuntu 中的 cx_Oracle:distutils.errors.DistutilsSetupError:找不到 Oracle 软件安装

zsh*_*bek 5 python oracle python-2.7

我尝试为 django 项目 sdu.edu.kz 安装 python 依赖项。本项目使用 cx-Oracle。当我尝试:

./install_python_dependencies.sh install
Run Code Online (Sandbox Code Playgroud)

它成功安装了除一个模块之外的所有模块。cx-Oracle 的模块。但是,我在我的计算机上安装了 cx-Oracle 程序。

它打印错误:

Collecting cx-oracle==5.2 (from -r requirements/base.txt (line 82))
  Using cached cx_Oracle-5.2.tar.gz
   Complete output from command python setup.py egg_info:
   Traceback (most recent call last):
     File "<string>", line 1, in <module>
     File "/tmp/pip-build-RP7c9i/cx-oracle/setup.py", line 170, in <module>
       raise DistutilsSetupError("cannot locate an Oracle software " \
   distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation

   ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip build-RP7c9i/cx-oracle/
Run Code Online (Sandbox Code Playgroud)

如何找到 Oracle 软件安装?有任何想法吗?请帮忙

rɑː*_*dʒɑ 4

对于 Oracle 12.x , cx_Oracle 尚不可用。所以我们需要下载11.x版本的即时客户端。

转至http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html并接受许可协议。

然后下载名称如下的 zip 文件

  • instantclient-sdk-linux.x64-11.2.0.4.0.zip
  • Instantclient-basic-linux.x64-11.2.0.4.0.zip

并使用 unzip 命令解压它们

unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip
unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
Run Code Online (Sandbox Code Playgroud)

两者都将被提取到名为“instantclient_11_2”的公共目录中。然后使用以下命令将其添加到 PATH 中。

export ORACLE_HOME=/path-to_this/instantclient_11_2
cd $ORACLE_HOME
ln -s libclntsh.so.11.1   libclntsh.so
Run Code Online (Sandbox Code Playgroud)

打开 /etc/profile 或 .bashrc 以及以下条目。

export ORACLE_HOME=/location/of/your/files/instantclient_11_2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
Run Code Online (Sandbox Code Playgroud)

然后做source ~/.bashrcsource /etc/profile

并安装这些包

sudo apt-get install build-essential unzip python-dev libaio-dev
Run Code Online (Sandbox Code Playgroud)

之后使用pip或者pip3根据你的Python版本然后安装它

pip3 install cx_Oracle
Run Code Online (Sandbox Code Playgroud)

并尝试cx_Oracle在Python解释器中加载模块。

希望这可以帮助。

信用在这里: https: //gist.github.com/kimus/10012910

注意:我已经在我的 Ubuntu 16.04 安装上尝试过这个,它应该适合你。