我通过搜索发现了类似的问题。然而,以前的解决方案似乎是围绕Windows而不是Linux。在
1)Python版本:Python 3.4.6
2)操作系统版本:Linux SLES 12.3
3)Oracle数据库版本:11.2
4)Oracle客户端:64位11.2 instant Client light,cx Oracle 6.4.1
5)李白:
S | Name | Summary | Type
---+---------------+------------------------------------------------------------+--------
i+ | libaio-devel | Development Files for Linux-native Asynchronous I/O Access | package
i | libaio1 | Linux-Native Asynchronous I/O Access Library | package
| libaio1-32bit | Linux-Native Asynchronous I/O Access Library | package
6)Oracle客户端位置:/opt/pyora/Oracle_11.2/instantclient_11_2
^{pr2}$7)下面的代码设置环境变量以及建立连接的尝试:(从python交互式shell运行)
from base64 import b64encode, b64decode # used for excoding/decoding base64 data
from toml import load as toml_load # used to retreive config file data
import cx_Oracle # used for accessing the Oracle databases
import os
import re
import sys
def decode_data(data):
return b64decode(data).decode('ascii')
path = os.environ["PATH"]
os.environ["PATH"] = "/opt/pyora/oracle_11.2/instantclient_11_2:" + path
os.environ["LD_LIBRARY_PATH"] = "/opt/pyora/oracle_11.2/instantclient_11_2"
os.environ["ORACLE_HOME"] = "/opt/pyora/oracle_11.2/instantclient_11_2"
os.environ["ORACLE_BASE"] = "/opt/pyora/oracle_11.2/instantclient_11_2"
username = decode_data("***")
password = decode_data("***")
hostname=decode_data("***")
port=decode_data("***")
schema=decode_data("***")
dsn ="{hostname}:{port}/{schema}".format(hostname=hostname,port=port,schema=schema)
print("PATH="+os.environ["PATH"]+"\n")
print("LS_LIBRARY_PATH="+os.environ["LD_LIBRARY_PATH"]+"\n")
print("ORACLE_HOME="+os.environ["ORACLE_HOME"]+"\n")
print("ORACLE_BASE="+os.environ["ORACLE_BASE"]+"\n")
dconn = cx_Oracle.connect(user=username,password=password,dsn=dsn)
8)收到的错误如下: 标准用户-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
Sudo'd User-(在导入cx\u Oracle之后)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libnnz11.so: cannot open shared object file: No such file or directory
我已经按照错误消息中找到的链接的说明进行了操作,但是没有任何帮助。 https://oracle.github.io/odpi/doc/installation.html#linux
我确实验证了各个部分的架构:
Oracle即时客户端: instantclient-basic-linux.x64-11.2.0.4.0.zip
李白:
libaio-devel-0.3.109-17.15.x86_64
libaio1-0.3.109-17.15.x86_64
Python 3:
Python 3.4.6 (default, Mar 01 2017, 16:52:22) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.architecture()
('64bit', 'ELF')
>>>
在启动应用程序之前设置库搜索路径。我建议使用
ldconfig
,如ODPI-C安装链接和实际的cx_Oracle installation doc所示。在使用Instant Client时,不要设置ORACLE®HOME或ORACLE®BASE。为什么要在应用程序内部设置路径??在
我还建议使用Instant Client 18.3,它可以连接到Oracle Database 11.2以后的版本。在
相关问题 更多 >
编程相关推荐