Python Anaconda - "import cx_Oracle" 命令错误 window

Python Anaconda - "import cx_Oracle" error in command window

我安装了 Python 2.7.7 :: Anaconda 2.0.1(64 位)。目前我正在尝试 运行 命令 "import cx_Oracle"。我 运行 easy_install 成功将 cx_Oracle egg 添加到 anaconda 目录的 "site_packages" 文件夹中,得到消息 "Installed c:\fast\anaconda.0.1\lib\site-packages\cx_oracle-5.1.3-py2.7-win-amd64"。' 现在,每当我在 python 终端中尝试命令 "import cx_Oracle" 时,我都会收到错误 "ImportError: DLL load failed: %1 is not a valid Win32 application"。我尝试安装 cx_Oracle 的特定 32 位版本,但它仍然产生相同的输出 "Installed c:\fast\anaconda.0.1\lib\site-packages\cx_oracle-5.1.3-py2.7-win-amd64"。 有没有人成功解决这个问题?

我安装了 32 位版本的 oracle 客户端。一旦我安装了 64 位版本,它工作正常。

您可以安装 cx_Oracle Python 软件包 as follows:

conda install -c https://conda.anaconda.org/anaconda cx_oracle

除其他事项外,它将负责安装正确的 Oracle 客户端:

C:\Anaconda>conda install -c https://conda.anaconda.org/anaconda cx_oracle
Fetching package metadata: ......
Solving package specifications: .
Package plan for installation in environment C:\Anaconda:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    oracle-instantclient-11.2.0.4.0|                0        50.9 MB
    cx_oracle-5.1.2            |           py27_0          55 KB
    pyyaml-3.11                |           py27_2         167 KB
    requests-2.8.0             |           py27_0         598 KB
    setuptools-18.3.2          |           py27_0         647 KB
    conda-3.18.1               |           py27_0         215 KB
    ------------------------------------------------------------
                                           Total:        52.5 MB

The following NEW packages will be INSTALLED:

    cx_oracle:            5.1.2-py27_0
    oracle-instantclient: 11.2.0.4.0-0

The following packages will be UPDATED:

    conda:                3.16.0-py27_0 --> 3.18.1-py27_0
    pyyaml:               3.11-py27_1   --> 3.11-py27_2
    requests:             2.7.0-py27_0  --> 2.8.0-py27_0
    setuptools:           18.1-py27_0   --> 18.3.2-py27_0

Proceed ([y]/n)? y

Fetching packages ...
oracle-instant 100% |###############################| Time: 0:00:04  11.48 MB/s
cx_oracle-5.1. 100% |###############################| Time: 0:00:00   1.77 MB/s
pyyaml-3.11-py 100% |###############################| Time: 0:00:00   2.14 MB/s
requests-2.8.0 100% |###############################| Time: 0:00:00   3.82 MB/s
setuptools-18. 100% |###############################| Time: 0:00:00   4.25 MB/s
conda-3.18.1-p 100% |###############################| Time: 0:00:00   1.11 MB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%

Oracle 客户端和 Python 平台必须相同(64 位或 32 位)

使用以下方式确定您当前的平台:

  import platform
  platform.architecture()

如果这对写作没有帮助,则默认安装的 5.3 版有问题。您可以尝试安装版本6.0b2

 python -m pip install cx_Oracle --pre

当 Anaconda 失败时。你可以试试pip。

Anaconda 3.5 (64bit Windows) Install cx_Oracle