【发布时间】:2014-04-10 04:02:10
【问题描述】:
我需要使用 python 连接到 Oracle 数据库。所以,我做了以下事情:
- 我从 Oracle 网站下载了 instantclient_11_2 basic 和 sdk。
- 把文件放在/opt/ora/instantclient
- 导出 ORACLE_HOME=/opt/ora/instantclient
- 导出 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
- cd $ORACLE_HOME && ln -s libclntsh.so.11.1 libclntsh.so
- 下载安装cx_Oracle-5.1.1-11g-py32-1.x86_64.rpm
但是当我尝试运行 import cx_Oracle 时,我得到了这个错误:
ImportError: No module named cx_Oracle
根据cx_Oracle site,我需要将文件 cx_Oracle.pyd 或 cx_Oracle.so 放在 Python 路径上的任何位置。但是安装 cx_Oracle-5.1.1-11g-py32-1.x86_64.rpm 后找不到那些文件..
顺便说一句,我也尝试使用压缩版本安装,但在构建时遇到很多错误,例如error: command 'gcc' failed with exit status 1
是不是我做错了什么?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p>解决了伙计们。我将我的 python 升级到最新版本,将 cx_Oracle 用于 python33 和 Instantclient11.2 ..
【问题讨论】:
-
您的操作系统/Linux 和版本是什么?
标签: python python-3.x cx-oracle