python - 设置 Cx_Oracle

标签 python database 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 客户端的目录。

我能想到的唯一问题是为 Oracle 10g 制作的 cx_Oracle 指的是客户端是 10g(我的是 9)而不是数据库(我的数据库是 10g)...或者说cx_Oracle 模块为“32 位”是指我的远程数据库为 32 位,而不是我的本地计算机。我尝试了一些不同的版本,但没有成功。

谢谢。

编辑:

另外,我被告知 Oracle 9 应该与 cx_Oracle 的某些版本一起使用..但是是哪些版本呢?我找不到这样的可用版本。这里有什么解决办法吗?

Edit:

I've updated to instantclient 10.2 on my local machine. Now, however, I can import cx_Oracle just fine but when I try to make a connection I get the following:

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

最佳答案

您的 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)。

关于python - 设置 Cx_Oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6444251/

相关文章:

python - 键在字典中时出现键错误

python - 快速求解数值方程

python - 使用已知列值更改 pandas DataFrame 多列中的值

mysql - MySQL中的时间戳除法

python - 数据库错误 : ORA-01036: illegal variable name/number

python - cx_Oracle 和输出变量

python - 口是心非在 macOS 上不起作用,得到 : env: python2: No such file or directory

mysql - 在MySQL中自动复制数据库结构

sql - 在 SQL What gets evaluated first 'where' or 'having'

python - SQLAlchemy 编解码器无法使用 Oracle WE8ISO8859P1 编码解码字节 0x81