1. 系统环境,linux, python3.5, pip
以下命令的执行均使用root用户。
2. 执行 pip install cx_Oracle
出错,提示不能定位Oracle的安装。出现该问题的原因是因为没有安装Oracle客户端相关的库文件。
下载文件:instantclient-basic-linux.x64-12.1.0.2.0.zip
下载链接:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
3. 解压下载到的文件,假设解压到 /opt/instantclient_12_1/ 这个目录
设置环境变量:export ORACLE_HOME=/opt/instantclient_12_1/
再次执行 pip install cx_Oracle
出错,提示编译过程未找到 oci.h 这个头文件。
4. 下载文件:instantclient-sdk-linux.x64-12.1.0.2.0.zip
下载链接:一致
解压下载到的文件,假设仍然解压到 /opt/instantclient_12_1/
5. 添加头文件的搜索路径:
export C_INCLUDE_PATH=/opt/instantclient_12_1/sdk/include/
再次执行:pip install cx_Oracle
编译成功,链接出错,提示 cannot find -lclntsh
6. 添加库搜索路径
export LD_LIBRARY_PATH=/opt