背景。
我的操作系统是Win7 64位。
我的 Python 是来自 python-2.7.8.amd64.msi 的 2.7 64 位
我的 cx_Oracle 是来自 cx_Oracle-5.0.4-10g-unicode.win-amd64-py2.7.msi 的 5.0 64 位
我的 Oracle 客户端是 10.1(我不知道 32 或 64 arch,但 SQL*Plus 是 10.1.0.2.0
数据库是
Oracle 数据库 10g 企业版 10.2.0.4.0 版 - 64 位
PL/SQL 版本 10.2.0.4.0 - 生产
核心 10.2.0.4.0 生产
适用于 64 位 Windows 的 TNS:版本 10.2.0.4.0 - 生产
NLSRTL 版本 10.2.0.4.0 - 生产
ORACLE_HOME 从 haki 回复中添加的变量。
C:\Oracle\product\10.1.0\Client_1\
无法正常工作的问题仍然存在。
ORACLE_HOME 从 instantclient-basic-win64-10.2.0.5.zip 试用 Oracle instant C:\instantclient_10_2\
C:\Users\PavilionG4>sqlplus Lee/123@chstchmp
错误 6 初始化 SQL*Plus
找不到消息文件 sp1.msb
SP2-0750:您可能需要将 ORACLE_HOME 设置为您的 Oracle 软件目录
我的sql*plus不让我设置Oracle。
ORACLE_HOME 回到
C:\Oracle\product\10.1.0\Client_1\
PATH 变量
C:\Program Files (x86)\Seagate Software\NOTES\
C:\Program Files (x86)\Seagate Software\NOTES\DATA\
C:\Program Files (x86)\Java\jdk1 .7.0_05\bin
C:\Oracle\product\10.1.0\Client_1\bin
C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin\client< br/>C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin
C:\app\PavilionG4\product\11.2.0\dbhome_1\bin
C:\app\PavilionG4\product\11.2.0\client_2\bin
c:\Program Files (x86)\AMD APP\bin\x86_64
c:\Program Files (x86)\AMD APP\bin\x86
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
C:\Users\PavilionG4\AppData\Local\Smartbar\Application\
C:\PROGRA~2\IBM\SQLLIB\BIN
C:\PROGRA~2\IBM\SQLLIB\FUNCTION
C:\Program Files\gedit\bin
C:\Kivy-1.7.2-w32< br/>C:\Program Files (x86)\ZBar\binj
C:\Program Files (x86)\Java\jdk1.7.0_05\bin
C:\Program Files\MATLAB\R2013a\运行时\win64
C:\Progra m 文件\MATLAB\R2013a\bin
C:\Python27
TNS 是:
C:\Oracle\product\10.1.0\Client_1\NETWORK\ADMIN\tnsnames.ora
报告 1 =
(描述 =
(地址列表 =
(地址 =(协议(protocol) = TCP)(主机 = 172.28.128.110)(端口 = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = REPORT1)
)
)
f1.py 显示错误
导入 cx_Oracle
ip = '172.25.25.42'
端口 = 1521
SID = 'REPORT1'
dns_tns = cx_Oracle.makedsn(ip,port,SID)
connection = cx_Oracle.connect(u"Lee",u"123",dns_tns)
游标 = connection.cursor()
connection.close()
错误
回溯(最近调用最后):
中的文件“f1.py”,第 6 行
connection = cx_Oracle.connect(u"Lee",u"123",dns_tns)
cx_Oracle.InterfaceError:无法获取 Oracle 环境句柄
问题
1、如何获取Oracle环境句柄?
我已经搜索过网站。不幸的是,它们根本没有解决我的问题。
2. 如何在不影响现有Oracle客户端的情况下让Python使用另一个Oracle客户端?
最佳答案
如果 python 在路径中找到多个 OCI.DLL 文件(即使它们相同),它会抛出此错误。 (您的路径语句看起来可能会抛出不止一个)。您可以操纵脚本中的路径来限制 python 查找支持的 ORACLE 文件的位置,如果您必须在本地运行多个版本的 oracle/clients,这可能是您唯一的选择。
关于Python + cx_Oracle : Unable to acquire Oracle environment handle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25542787/