Alex F
Alex F

Reputation: 2284

Python Anaconda - "import cx_Oracle" error in command window

I installed Python 2.7.7 :: Anaconda 2.0.1 (64-bit). Currently I am trying to run the command "import cx_Oracle". I ran easy_install which successfully add the cx_Oracle egg to the "site_packages" folder the anaconda directory getting the message "Installed c:\fast\anaconda\2.0.1\lib\site-packages\cx_oracle-5.1.3-py2.7-win-amd64".' Now whenever I try the command "import cx_Oracle" in the python terminal I get the error "ImportError: DLL load failed: %1 is not a valid Win32 application". I tried installing the specific 32-bit version of cx_Oracle but it still resulted in the same output "Installed c:\fast\anaconda\2.0.1\lib\site-packages\cx_oracle-5.1.3-py2.7-win-amd64". Has anyone had success fixing this?

Upvotes: 4

Views: 7505

Answers (3)

pmi
pmi

Reputation: 351

Oracle client and Python platform must be the same (64 or 32-bit)

Determine Your current platform using:

  import platform
  platform.architecture()

If this won't help in the of writing there is trouble with default installed version 5.3. You can try to install Version 6.0b2

 python -m pip install cx_Oracle --pre

When Anaconda fails. You can try pip.

Anaconda 3.5 (64bit Windows) Install cx_Oracle

Upvotes: 0

Franck Dernoncourt
Franck Dernoncourt

Reputation: 83147

You can install the cx_Oracle Python package as follows:

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

Amongst other things, it will take care of installing the right Oracle client:

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%

Upvotes: 3

Alex F
Alex F

Reputation: 2284

I had the 32-bit version of oracle client installed. Once I installed the 64-bit version it worked fine.

Upvotes: 1

Related Questions