Python cx_Oracle:ImportError:DLL 加载失败:此应用程序失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20159566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cx_Oracle: ImportError: DLL load failed: This application has failed
提问by RubenGeert
Here's what I did:
这是我所做的:
- I'm on Windows XP SP3
- I already had Python 2.7.1 installed.
- I downloaded
instantclient-basic-nt-11.2.0.3.0.zip, unzipped it, and put it inC:\Program Files\Oracle\instantclient_11_2. - I added this path to the Windows
Pathenvironment variable. - I created a new environment variable
ORACLE_HOMEholding this path as its value. - I installed
cx_Oracle-5.1.2-11g.win32-py2.7.msi.
- 我使用的是 Windows XP SP3
- 我已经安装了 Python 2.7.1。
- 我下载了
instantclient-basic-nt-11.2.0.3.0.zip,解压,然后放进去C:\Program Files\Oracle\instantclient_11_2。 - 我将此路径添加到 Windows
Path环境变量中。 - 我创建了一个新的环境变量,
ORACLE_HOME将此路径作为其值。 - 我安装了
cx_Oracle-5.1.2-11g.win32-py2.7.msi.
And on running import cx_Oracleall I get is
在跑步时,import cx_Oracle我得到的只是
Traceback (most recent call last):
File "<string>", line 2, in <module>
ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
I obviously uninstalled / reinstalled cx_Oracle a couple of times but really nothing seems to help. Could anyone please provide a clue how to fix this?
我显然卸载/重新安装了 cx_Oracle 几次,但似乎没有任何帮助。任何人都可以提供如何解决这个问题的线索吗?
UPDATE
更新
I ran Dependency Walker and it comes up with a lot of trouble. However, the first missing .dll (msvcr80.dll) is actually presentin C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.91_x-ww_0de56c07.
我运行了 Dependency Walker,但遇到了很多麻烦。但是,第一个丢失的 .dll (msvcr80.dll) 实际上存在于C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.91_x-ww_0de56c07.


回答by RubenGeert
OK, what finally solved the problem (not sure whether all steps are necessary and no idea why exactly this and only this worked so far):
好的,最终解决了问题的是什么(不确定是否所有步骤都是必要的,也不知道为什么会这样,到目前为止只有这样有效):
回答by greatvovan
To help other people with the same problem:
帮助其他有同样问题的人:
This error tells about 32-64 bit mismatch between some DLL while importing module. Possibilities are:
此错误说明导入模块时某些 DLL 之间存在 32-64 位不匹配。可能性是:
- Different architecture of Python and cx_Oracle (less probable since cx_Oracle installer on Windows warns you if appropriate Python was not found).
- Different architecture of cx_Oracle libraries and oci.dll (more probable).
- Python 和 cx_Oracle 的不同架构(不太可能,因为 Windows 上的 cx_Oracle 安装程序会在未找到合适的 Python 时警告您)。
- cx_Oracle 库和 oci.dll 的不同架构(更有可能)。
Keep in mind that cx_Oracle uses standart Oracle client (at OCI level) which must be installed on your machine. It searches for oci.dll in several places, including PATH. If it founds oci.dll of wrong version of client the error appears.
请记住,cx_Oracle 使用必须安装在您的机器上的标准 Oracle 客户端(在 OCI 级别)。它在多个位置搜索 oci.dll,包括PATH。如果发现 oci.dll 的客户端版本错误,则会出现错误。
In case you get this error check path list in the PATHenvironment variable. It is likely to contain path to BIN folder of wrong version of Oracle client. If you have several clients, specify in the PATHthe appropriate one or install appropriate client.
如果您在PATH环境变量中收到此错误,请检查路径列表。它可能包含错误版本的 Oracle 客户端的 BIN 文件夹的路径。如果您有多个客户端,请在PATH 中指定合适的客户端或安装合适的客户端。
NOTE:ORACLE_HOME does not have an effect for cx_Oracle. In my case only changing of PATH helped. I think the Ruben's solution works because of item 3 ('Add this same path to the "Path" environment variable').
注意:ORACLE_HOME 对 cx_Oracle 没有影响。在我的情况下,只有改变 PATH 有帮助。我认为 Ruben 的解决方案之所以有效,是因为第 3 项(“将相同的路径添加到“路径”环境变量中)。
回答by rob
Easy way:
简单的方法:
- Make sure you have installed cx-Oracle, I have
cx_Oracle-5.1.3-11g.win32-py2.7.exe - Download, unzip
instantclient_12_1and move it toC:\Python27 - Add environment variable
C:\Python27\instantclient_12_1 - Restart your computer
- 确保你已经安装了 cx-Oracle,我有
cx_Oracle-5.1.3-11g.win32-py2.7.exe - 下载、解压
instantclient_12_1并移动到C:\Python27 - 添加环境变量
C:\Python27\instantclient_12_1 - 重启你的电脑
回答by Marcelo Assis
As is the second time I came to this question, I feel the need to post what I did:
就像我第二次遇到这个问题一样,我觉得有必要发布我所做的:
I'm using:
我正在使用:
- Win 8 64 bits
- Python 2.7
- 赢8 64位
- 蟒蛇 2.7
I had no success installing Python and cx_Oracle 64 bits.
我没有成功安装 Python 和 cx_Oracle 64 bits。
It only worked when I tried 32 bits versions and followed @rob answer instructions
它仅在我尝试 32 位版本并遵循 @rob 回答说明时才有效
回答by user3819536
If you're using conda as a package manager, one way to overcome the DLL issue it to install oracle-instantclient by doing a conda install oracle-instantclient. This fixed the dependency which I couldn't fix by manually installing Oracle's instant-client.
如果您使用 conda 作为包管理器,克服 DLL 问题的一种方法是通过执行conda install oracle-instantclient. 这修复了我无法通过手动安装 Oracle 的即时客户端来修复的依赖项。
回答by Sergey Stepanov
Same ImportErroroccured for setup of:
ImportError设置也发生了同样的情况:
- Windows 10 x64
- Oracle Instant Client 12_1 x64
- Python 2.7.11 x64
- cx_Oracle cx_Oracle-5.2-12c.win-amd64-py2.7
- 视窗 10 x64
- Oracle 即时客户端 12_1 x64
- Python 2.7.11 x64
- cx_Oracle cx_Oracle-5.2-12c.win-amd64-py2.7
I solved it copying msvcr100.dllfile into <oracle_instant_client_dir>
我解决了将msvcr100.dll文件复制到<oracle_instant_client_dir>
回答by Jaya Nandan
I am using python35 64 bit and oracle express on win 7 (64 bit).
I installed cx_Oracle using pip3 (pip3 install cx_Oracle) instead of downloading the installer from pypi.
我在win 7(64位)上使用python35 64位和oracle express。我使用 pip3 ( pip3 install cx_Oracle)安装了 cx_Oracle而不是从 pypi 下载安装程序。
I faced the same problem.
我遇到了同样的问题。
I solved it by following above guidelines, but instead of 32 bit client, I downloaded the 64 bit version of the instant client (instantclient-basic-windows.x64-11.2.0.4.0.zip) from http://www.oracle.com/technetwork/topics/winx64soft-089540.html.
我按照上述指南解决了这个问题,但我没有下载 32 位客户端,而是从http://www.oracle下载了 64 位版本的即时客户端 (instantclient-basic-windows.x64-11.2.0.4.0.zip) .com/technetwork/topics/winx64soft-089540.html。
I then extracted it to c:\oraclexe. And added these environment variables
然后我将其解压缩到 c:\oraclex。并添加了这些环境变量
set ORACLE_BASE=C:\oraclexe
set ORACLE_HOME=C:\oraclexe\app\oracle\product.2.0\server
set PATH=C:\oraclexe\instantclient_11_2;%PATH%
And ran my django migrate commands:
python manage.py migrate
并运行我的 django migrate 命令:
python manage.py migrate
It worked excellent
它工作得很好
回答by maxim
I had same issue with DLL load failed on my Windows machine. installed oracle client, set variables, ran cx_Oracle-5.1.3-11g.win32-py2.7.exe file.
我在 Windows 机器上遇到了同样的 DLL 加载失败问题。安装 oracle 客户端,设置变量,运行 cx_Oracle-5.1.3-11g.win32-py2.7.exe 文件。
however when I installed cx_Oracle with easy_setup it fixed the problem.
但是,当我使用 easy_setup 安装 cx_Oracle 时,它解决了这个问题。
C:\Python27\Scripts\easy_install.exe cx_Oracle-5.1.3-11g.win32-py2.7.exe
回答by rupesh patil
Steps I have followed :
我遵循的步骤:
Downloaded the smart client instantclient-basic-windows.x64-12.1.0.2.0.zip
Extracted and copied to #your directory#\instantclient_12_1
Above directory contains dll's
Append the PATH variable with #your directory#\instantclient_12_1 and created env variable ORACLE_HOME= #your directory#\instantclient_12_1
Download and install cx_Oracle-5.2.1-11g.win-amd64-py2.7.exe
Open idle type import cx_Oracle
下载智能客户端instantclient-basic-windows.x64-12.1.0.2.0.zip
提取并复制到#your directory#\instantclient_12_1
上面的目录包含dll的
将 PATH 变量附加到 #your directory#\instantclient_12_1 并创建环境变量 ORACLE_HOME= #your directory#\instantclient_12_1
下载并安装 cx_Oracle-5.2.1-11g.win-amd64-py2.7.exe
打开空闲类型导入cx_Oracle
回答by user6405238
if you're using Anaconda on Windows try:
如果您在 Windows 上使用 Anaconda,请尝试:
conda install cx_oracle
on your cmd
在你的 cmd 上
-> this
-> 这个

