设置 Cx_Oracle
我正在运行...
SQL*Plus: Release 9.2.X.X.X - Production on Wed Jun 22 13:02:14 2011
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.X.X.X - 64bit Production
With the Partitioning, OLAP and Data Mining options
使用的是Python 2.7.1版本。
我安装了适用于Oracle 10g的32位cx_Oracle,但在尝试导入时遇到了以下问题:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import cx_Oracle
ImportError: DLL load failed: The specified procedure could not be found.
我检查过我的%ORACLE_HOME%
环境变量,它设置为我安装Oracle客户端的目录。
我能想到的唯一问题是,cx_Oracle是为Oracle 10g制作的,但它可能是指客户端是10g(而我的客户端是9),而不是数据库(我的数据库是10g)……或者cx_Oracle模块的“32位”是指我的远程数据库是32位,而不是我的本地机器。我尝试了不同版本的组合,但都没有成功。
谢谢。
编辑:
另外,我听说Oracle 9应该可以与某些版本的cx_Oracle一起使用……但具体是哪些版本呢?我找不到这样的版本。这里有没有什么解决办法?
编辑:
我在本地机器上更新到了instantclient 10.2。现在,我可以顺利导入cx_Oracle,但当我尝试建立连接时,出现了以下问题:
Traceback (most recent call last):
File "C:\oracleTest.py", line 2, in <module>
connection = cx_Oracle.connect("username/password@(DESCRIPTION STRING)")
DatabaseError: ORA-12705: Cannot access NLS data files or invalid environment specified
1 个回答
1
你的Oracle客户端版本应该和cx_Oracle的版本一致。你为什么要使用Oracle 9的客户端呢?其实你可以直接下载并安装10版(甚至11版)的客户端,然后再对应安装相应的cx_Oracle版本。这样的话,它们都能和Oracle 10g一起正常工作。
我们公司用的是Oracle 10g,而我用的是11g的客户端(还有对应的cx_Oracle版本)。
补充:我在这里找到了几个旧版本的cx_Oracle:http://sourceforge.net/projects/cx-oracle/files/
...不过,如果你想用那些适配Oracle 9客户端的版本,可能需要一个较旧的Python版本(2.6)。