cx_Oracle模块安装错误消息

问题描述:

我使用Python 2.7(32位)和我的操作系统是64位Windows 7cx_Oracle模块安装错误消息

我试图安装cx_Oracle模块。我运行了msi“cx_Oracle-5.1.2-10g.win32-py2.7.msi”,然后我在cmd行运行“easy_install cx_Oracle”,并得到以下消息:

错误:无法找到vcvarsall .BAT

我在这个网站,最好的解决办法是安装Microsoft Visual Studio 2008中,这是我从一个链接我在此网站上发现没发现。

现在,当我运行CMD线我得到以下信息,我不知道这意味着什么“的easy_install cx_Oracle”:

C:\Python27>easy_install cx_Oracle Searching for cx-Oracle Reading ....org/simple/cx_Oracle/ Reading ....net/crew/atuining Reading ...sourceforge.net Best match: cx-Oracle 5.1.2 Downloading http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2.tar.gz ? download Processing cx_Oracle-5.1.2.tar.gz Writing c:\users\cnielsen\appdata\local\temp\easy_install-44rupd\cx_Oracle-5.1.2 \setup.cfg Running cx_Oracle-5.1.2\setup.py -q bdist_egg --dist-dir c:\users\cnielsen\appda ta\local\temp\easy_install-44rupd\cx_Oracle-5.1.2\egg-dist-tmp-eyihnb Traceback (most recent call last): File "C:\Python27\Scripts\easy_install-script.py", line 9, in load_entry_point('setuptools==0.8', 'console_scripts', 'easy_install')() File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1992 , in main File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1979 , in with_ei_usage File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1996 , in File "C:\Python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 380, in run File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 623, in easy_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 653, in install_item File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 849, in install_eggs File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1130 , in build_and_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1115 , in run_setup File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 69, in run_setup File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 120, in run File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 71, in File "setup.py", line 350, in File "C:\Python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\bdist_egg.py", line 185, in run File "build\bdist.win-amd64\egg\setuptools\command\bdist_egg.py", line 171, in call_command File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command self.distribution.run_command(command) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\install_lib.py", line 20, i n run File "C:\Python27\lib\distutils\command\install_lib.py", line 111, in build self.run_command('build_ext') File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command self.distribution.run_command(command) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\build_ext.py", line 52, in run File "C:\Python27\lib\distutils\command\build_ext.py", line 339, in run self.build_extensions() File "C:\Python27\lib\distutils\command\build_ext.py", line 448, in build_exte nsions self.build_extension(ext) File "build\bdist.win-amd64\egg\setuptools\command\build_ext.py", line 186, in build_extension File "C:\Python27\lib\distutils\command\build_ext.py", line 498, in build_exte nsion depends=ext.depends) File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile self.initialize() File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize vc_env = query_vcvarsall(VERSION, plat_spec) File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsal l raise ValueError(str(list(result.keys()))) ValueError: [u'path']

搜索后3天,我终于解决了这个问题。

诀窍是:

  1. 安装vcredist_x86.exe。 安装此之后,我跑easy_install cx_Oracle,不再看到原始的错误消息。
  2. 重新安装Python 2.7.5,确保它是32位版本(x86)的
  3. 重新安装IDE “PyScripter”,确保它是32位版本(x86)的
+0

顺便说一句:我用的vcredist_x86.exe被找到了这里:http://www.microsoft.com/en-us/download/confirmation.aspx?id=29 –

的easy_install的步骤尝试编译在cx_Oracle源的机器,但这不是必需的,因为您已经安装了MSI,它是一个预编译的二进制版本。

您所安装的MSI应该足够使用cx_Oracle,只要你有二进制Oracle客户端安装好了(例如,instantclient)。

+0

谢谢。我无法弄清楚如何安装Oracle即时客户端,因为没有msi,但我下载了它并将其路径添加到ENV PATH。然后我重新安装了Python 2.7 32位。现在我似乎有了cx_Oracle模块,但是当我尝试在Python脚本中调用模块时,我收到了这条新消息:...将cx_Oracle导入为oracle文件“build \ bdist.win32 \ egg \ cx_Oracle.py”,行7,在文件“build \ bdist.win32 \ egg \ cx_Oracle.py”,第6行,在__bootstrap__ ImportError:DLL加载失败:%1不是有效的Win32应用程序。 >>> –

+0

有帮助... http://*.com/questions/20159566/cx-oracle-importerror-dll-load-failed-this-application-has-failed – user584583

重申莱昂德罗说什么,你不需要easy_install的cx_Oracle如果你已经跑了.msi安装,你需要安装oracle的instantclient。

正如你已经发现了,在安装Oracle instantclient意味着你只需要简单地把它解压到您的系统文件夹(例如:C:\ oraclient)。

有些事情要记住:

确保您使用cx_Oracle,instantclient相同版本(或兼容版本),以及数据库服务器本身。例如instantclient v12不支持版本10以下的数据库服务器)。此外,请确保您使用的是全部32位或全部64位版本(包括cx_Oracle,instantclient和python本身)。

此外,您需要将环境变量ORACLE_HOME和PATH设置到解压缩oracle instantclient的目录(例如:C:\ oraclient)以避免您提到的ImportError错误(DLL加载失败:%1为不是有效的Win32应用程序)。 ImportError仅仅意味着它找不到所需的库。

由于cx_Oracle只能使用Oracle TNS名称工具进行连接,因此您可能还需要设置TNS_ADMIN环境变量以指示要使用的TNS名称文件的位置。这个问题也咬我。

对于Windows 7 64位,您需要“Windows amd64安装程序(Oracle 11g,Python 3.3)”。它也适用于英特尔。

我没有InstantClient,但使用Oracle 11.2安装(64位)中的SQL * Plus。