I recently installed cx_Oracle module on my machine, in order to connect to a remote Oracle database server. (I have no Oracle client at my side).
我最近在我的机器上安装了cx_Oracle模块,以便连接到远程Oracle数据库服务器。(我身边没有Oracle客户)。
- Python: Version 2.7 x86
- Python:x86 2.7版本
- Oracle: Verision 11.1.X x64
- Oracle:Verision 11.1。X x64
- Cx_Oracle:Verion-5.1.2-11g.win32-py2.7
- Cx_Oracle:Verion-5.1.2-11g.win32-py2.7
Then everytime I run my script, it fails and print the following message:
然后每次我运行脚本时,它都会失败并打印如下消息:
ImportError: DLL load failed: The specified module could not be found.
ImportError: DLL加载失败:找不到指定模块。
I found a related post at Here, so I am wondering if I anyway have to have an Oracle client at my side where the python script is invoked.
我在这里找到了一篇相关的文章,所以我想知道我是否必须在我的旁边有一个Oracle客户端,在那里调用python脚本。
Can anyone help me out? Thanks in advance.
谁能帮我一下吗?提前谢谢。
4 个解决方案
#1
6
Yes, you have to have an Oracle client installed at your side.
是的,您必须在您这边安装Oracle客户端。
From the cx_ORacle README
从cx_ORacle自述
"Please note that an Oracle client (or server) installation is required in order to use cx_Oracle. If you do not require the tools that come with a full client installation, it is recommended to install the Instant Client which is far easier to install."
请注意,使用cx_Oracle需要安装Oracle客户端(或服务器)。如果您不需要带有完整客户端安装的工具,建议您安装即时客户端,这样安装起来要容易得多。
EDIT link to Instant Client: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
编辑到即时客户端的链接:http://www.oracle.com/technetwork/database/features/instantclient/index -097480.html
#2
10
# - This import requires appropriate oraocciXX.dll to be available in PATH (on windows)
# (Probably LD_LIBRARY_PATH or LD_LIBRARY_PATH64 on POSIX)
# where XX is the oracle DB version, e.g. oraocci11.dll for Oracle 11g.
# - This dll is part of the Oracle Instant client pkg available here:
# http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
# - Also ensure that python, cx_Oracle and Oracle Client are of same arch (32 or 64-bit)
#
import cx_Oracle
You can find out arch (32 or 64-bit) for:
你可以找到arch(32位或64位):
- python by just running the python in interactive mode on command line.
- 通过在命令行上以交互模式运行python来实现。
- cx_Oracle: look at the name of downloaded file.
- cx_Oracle:查看下载文件的名称。
- Oracle Client:
- run the sqlplus that's part of your client package
- 运行作为客户端包一部分的sqlplus
- start Task Manager and see if sqlplus.exe has "*32" next to it (=32 bit) or not (=64 bit)
- 启动任务管理器,查看是否sqlplus。exe的旁边有"*32"(=32位)或不是(=64位)
- if you don't have sqlplus, use
dumpbin /headers oraocciXX.dll
- 如果没有sqlplus,请使用dumpbin /header oraocciXX.dll
- Oracle客户端:运行作为客户端包启动任务管理器一部分的sqlplus,并查看sqlplus是否存在。exe的旁边有“*32”(=32位)或没有(=64位)如果没有sqlplus,可以使用dumpbin /header oraocciXX.dll
- If you're using POSIX you probably would already know. Use
file oraocciXX.so
- 如果你使用POSIX,你可能已经知道了。使用文件oraocciXX.so
Finally if you still don't understand here is really for dummies instructions:
最后,如果你还是不明白,这里真的是假人指导:
- Ensure you've installed 32-bit versions of python, cx_Oracle and Oracle Instant Client. These could also be 64-bit, but must be same for all 3. Can not mix and match. Links:
-
Oracle Instant Client Lets say it's installed in
C:\ProgFiles\OraClient\11_2
- Oracle Instant Client let say it is installed in C:\ProgFiles\OraClient\ \11_2
- cx_Oracle
- cx_Oracle
- Python
- Python
-
Oracle Instant Client Lets say it's installed in
- 确保您已经安装了python、cx_Oracle和Oracle Instant Client的32位版本。它们也可以是64位的,但对所有3都是相同的。不能混搭。链接:Oracle Instant Client let let say it is installed in C:\ProgFiles\OraClient\11_2 cx_Oracle Python
- Windows:
set PATH=%PATH%;C:\ProgFiles\OraClient\11_2
- 设置路径= % %路径;C:\ ProgFiles 11 _2 \ OraClient \
- Windows:设置路径= % %路径;C:\ ProgFiles 11 _2 \ OraClient \
- POSIX (Linux/Unix/Solaris...) <-- Untested..
export LD_LIBRARY_PATH=/path/to/your/32bit/oraocciXX.so
- 出口LD_LIBRARY_PATH = /道路/ /你/ 32位/ oraocciXX.so
- (64 bit)
export LD_LIBRARY_PATH64=/path/to/your/64bit/oraocciXX.so
- (64位)出口LD_LIBRARY_PATH64 = /道路/ /你/ 64位/ oraocciXX.so
- POSIX(Linux / Unix / Solaris…)<——未经测试. .出口LD_LIBRARY_PATH = /道路/ /你/ 32位/ oraocciXX。所以(64位)导出LD_LIBRARY_PATH64=/path/到/your/64bit/ oraoccixxso
- run
path-to-python/python.exe -c "import cx_Oracle"
to test whether your setup is working or not.- if it prints
- 如果它打印
- nothing: then it's successful.
- 什么:那么成功。
-
ImportError: DLL load failed: The specified module could not be found
: then oraocciXX is not found. Setup the env vars correctly. - ImportError: DLL加载失败:找不到指定模块:找不到oraocciXX。正确设置env vars。
-
ImportError: DLL load failed: %1 is not a valid Win32 application
: You have a 32/64 bit mismatch. - impor: DLL加载失败:%1不是有效的Win32应用程序:您有32/64位错配。
- 运行path-to-python / python。exe -c“导入cx_Oracle”以测试您的设置是否有效。如果它什么都不打印,那么它就是成功的。ImportError: DLL加载失败:找不到指定模块:找不到oraocciXX。正确设置env vars。impor: DLL加载失败:%1不是有效的Win32应用程序:您有32/64位错配。
#3
2
After having been trying to solve this issue for days, I found out that set PATH=%PATH%:<insert Oracle home here>
did not do the trick for me. I had to go into my Windows XP system properties and append the Oracle home to the 'path' variable under 'System variables'.
在尝试解决这个问题几天之后,我发现set PATH=%PATH%: <插入oracle home在这里,> 并没有为我做什么。我必须进入我的Windows XP系统属性,并将Oracle home附加到“系统变量”下的“路径”变量。
#4
0
I cannot comment yet :-( but for uniquephase above, you may want to try to check the permissions of the .exe and .dlls to make sure they are executable?
我还不能评论:-(但是对于上面的uniquephase,您可能想要检查.exe和.dll的权限,以确保它们是可执行的?
So the steps I needed to do to get it working.
所以我需要做的是让它工作。
Unzip the instant client from here. http://www.oracle.com/technetwork/topics/winx64soft-089540.html
从这里解压缩即时客户端。http://www.oracle.com/technetwork/topics/winx64soft - 089540. - html
chmod +x *.exe *.dll (I am using cygwin).
chmod + x *。exe *。dll(我正在使用cygwin)。
For completeness, I couldnt get cx_oracle to install via pip using cygwin.
为了完整性起见,我无法让cx_oracle使用cygwin通过pip进行安装。
So I had to use standard dist python (non-cygwin) and installed cx_oracle via the windows installer.
因此,我必须使用标准的dist python(非cygwin)并通过windows安装程序安装cx_oracle。
Also, I had to add f:/opt/instantclient_12_1 (location where I installed the Oracle instant client) to the Windows path (via System->Advanced System Properties->Environment Variables->System Variables).
此外,我还必须向Windows路径添加f:/opt/instantclient_12_1(安装Oracle instantclient的位置)(通过System->高级系统属性->环境变量->系统变量)。
#1
6
Yes, you have to have an Oracle client installed at your side.
是的,您必须在您这边安装Oracle客户端。
From the cx_ORacle README
从cx_ORacle自述
"Please note that an Oracle client (or server) installation is required in order to use cx_Oracle. If you do not require the tools that come with a full client installation, it is recommended to install the Instant Client which is far easier to install."
请注意,使用cx_Oracle需要安装Oracle客户端(或服务器)。如果您不需要带有完整客户端安装的工具,建议您安装即时客户端,这样安装起来要容易得多。
EDIT link to Instant Client: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
编辑到即时客户端的链接:http://www.oracle.com/technetwork/database/features/instantclient/index -097480.html
#2
10
# - This import requires appropriate oraocciXX.dll to be available in PATH (on windows)
# (Probably LD_LIBRARY_PATH or LD_LIBRARY_PATH64 on POSIX)
# where XX is the oracle DB version, e.g. oraocci11.dll for Oracle 11g.
# - This dll is part of the Oracle Instant client pkg available here:
# http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
# - Also ensure that python, cx_Oracle and Oracle Client are of same arch (32 or 64-bit)
#
import cx_Oracle
You can find out arch (32 or 64-bit) for:
你可以找到arch(32位或64位):
- python by just running the python in interactive mode on command line.
- 通过在命令行上以交互模式运行python来实现。
- cx_Oracle: look at the name of downloaded file.
- cx_Oracle:查看下载文件的名称。
- Oracle Client:
- run the sqlplus that's part of your client package
- 运行作为客户端包一部分的sqlplus
- start Task Manager and see if sqlplus.exe has "*32" next to it (=32 bit) or not (=64 bit)
- 启动任务管理器,查看是否sqlplus。exe的旁边有"*32"(=32位)或不是(=64位)
- if you don't have sqlplus, use
dumpbin /headers oraocciXX.dll
- 如果没有sqlplus,请使用dumpbin /header oraocciXX.dll
- Oracle客户端:运行作为客户端包启动任务管理器一部分的sqlplus,并查看sqlplus是否存在。exe的旁边有“*32”(=32位)或没有(=64位)如果没有sqlplus,可以使用dumpbin /header oraocciXX.dll
- If you're using POSIX you probably would already know. Use
file oraocciXX.so
- 如果你使用POSIX,你可能已经知道了。使用文件oraocciXX.so
Finally if you still don't understand here is really for dummies instructions:
最后,如果你还是不明白,这里真的是假人指导:
- Ensure you've installed 32-bit versions of python, cx_Oracle and Oracle Instant Client. These could also be 64-bit, but must be same for all 3. Can not mix and match. Links:
-
Oracle Instant Client Lets say it's installed in
C:\ProgFiles\OraClient\11_2
- Oracle Instant Client let say it is installed in C:\ProgFiles\OraClient\ \11_2
- cx_Oracle
- cx_Oracle
- Python
- Python
-
Oracle Instant Client Lets say it's installed in
- 确保您已经安装了python、cx_Oracle和Oracle Instant Client的32位版本。它们也可以是64位的,但对所有3都是相同的。不能混搭。链接:Oracle Instant Client let let say it is installed in C:\ProgFiles\OraClient\11_2 cx_Oracle Python
- Windows:
set PATH=%PATH%;C:\ProgFiles\OraClient\11_2
- 设置路径= % %路径;C:\ ProgFiles 11 _2 \ OraClient \
- Windows:设置路径= % %路径;C:\ ProgFiles 11 _2 \ OraClient \
- POSIX (Linux/Unix/Solaris...) <-- Untested..
export LD_LIBRARY_PATH=/path/to/your/32bit/oraocciXX.so
- 出口LD_LIBRARY_PATH = /道路/ /你/ 32位/ oraocciXX.so
- (64 bit)
export LD_LIBRARY_PATH64=/path/to/your/64bit/oraocciXX.so
- (64位)出口LD_LIBRARY_PATH64 = /道路/ /你/ 64位/ oraocciXX.so
- POSIX(Linux / Unix / Solaris…)<——未经测试. .出口LD_LIBRARY_PATH = /道路/ /你/ 32位/ oraocciXX。所以(64位)导出LD_LIBRARY_PATH64=/path/到/your/64bit/ oraoccixxso
- run
path-to-python/python.exe -c "import cx_Oracle"
to test whether your setup is working or not.- if it prints
- 如果它打印
- nothing: then it's successful.
- 什么:那么成功。
-
ImportError: DLL load failed: The specified module could not be found
: then oraocciXX is not found. Setup the env vars correctly. - ImportError: DLL加载失败:找不到指定模块:找不到oraocciXX。正确设置env vars。
-
ImportError: DLL load failed: %1 is not a valid Win32 application
: You have a 32/64 bit mismatch. - impor: DLL加载失败:%1不是有效的Win32应用程序:您有32/64位错配。
- 运行path-to-python / python。exe -c“导入cx_Oracle”以测试您的设置是否有效。如果它什么都不打印,那么它就是成功的。ImportError: DLL加载失败:找不到指定模块:找不到oraocciXX。正确设置env vars。impor: DLL加载失败:%1不是有效的Win32应用程序:您有32/64位错配。
#3
2
After having been trying to solve this issue for days, I found out that set PATH=%PATH%:<insert Oracle home here>
did not do the trick for me. I had to go into my Windows XP system properties and append the Oracle home to the 'path' variable under 'System variables'.
在尝试解决这个问题几天之后,我发现set PATH=%PATH%: <插入oracle home在这里,> 并没有为我做什么。我必须进入我的Windows XP系统属性,并将Oracle home附加到“系统变量”下的“路径”变量。
#4
0
I cannot comment yet :-( but for uniquephase above, you may want to try to check the permissions of the .exe and .dlls to make sure they are executable?
我还不能评论:-(但是对于上面的uniquephase,您可能想要检查.exe和.dll的权限,以确保它们是可执行的?
So the steps I needed to do to get it working.
所以我需要做的是让它工作。
Unzip the instant client from here. http://www.oracle.com/technetwork/topics/winx64soft-089540.html
从这里解压缩即时客户端。http://www.oracle.com/technetwork/topics/winx64soft - 089540. - html
chmod +x *.exe *.dll (I am using cygwin).
chmod + x *。exe *。dll(我正在使用cygwin)。
For completeness, I couldnt get cx_oracle to install via pip using cygwin.
为了完整性起见,我无法让cx_oracle使用cygwin通过pip进行安装。
So I had to use standard dist python (non-cygwin) and installed cx_oracle via the windows installer.
因此,我必须使用标准的dist python(非cygwin)并通过windows安装程序安装cx_oracle。
Also, I had to add f:/opt/instantclient_12_1 (location where I installed the Oracle instant client) to the Windows path (via System->Advanced System Properties->Environment Variables->System Variables).
此外,我还必须向Windows路径添加f:/opt/instantclient_12_1(安装Oracle instantclient的位置)(通过System->高级系统属性->环境变量->系统变量)。