在Windows 7上安装cx_Oracle时出错

时间:2017-02-15 05:35:47

标签: python oracle cx-oracle

TypeError:不支持的Python数据类型:file

Spyder console error

In [9]: import cxOracle
Traceback (most recent call last):

  File "<ipython-input-9-d1ecebcba3d2>", line 1, in <module>
    import cx_Oracle

ImportError: DLL load failed: %1 is not a valid Win32 application.

Command prompt error

C:\Users\system.labuser>pip install cx_Oracle
Collecting cs_Oracle
  Using cached cx_Oracle-5.2.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback <most recent call last>:
      File "<string>", line 1, in <module>
      File "c:\users\system~1.lab\appdata\local\temp\pip-build-5bnyuh\cx-Oracle\setup.py", line 170, in <module>
        raise DistutilsSetupError<"cannot locate an Oracle software " \
    distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\system~1.lab\appdata\local\temp\pip-build-5bnyuh\cx-Oracle\

提到this question。问题仍然存在。我使用的是Windows 7 64位PC。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

检查您使用的是哪种类型的Python - 32位或64位。然后转到PyPI(https://pypi.python.org/pypi/cx_Oracle/5.2.1)并下载正确的版本(正确的Python版本以及32位或64位,具体取决于您使用的是什么Python)。预建的二进制文件可以让你解决第一个问题。

您还需要确保已安装Oracle客户端并且它位于PATH中。您可以从此位置(http://www.oracle.com/technetwork/database/features/instant-client/index.html)获取Oracle即时客户端,并按照该页面上的说明进行操作。同样,请确保下载32位或64位,具体取决于您使用的Python版本和cx_Oracle。一切都必须匹配,否则你会得到你注意到的问题。

相关问题