I'm trying to install the cx_Oracle for Python 2.6, but it is failing. I don't know enough about C or MS Vis. Studio's compiler to even approach fixing it myself.
This is what is output on the command line:
C:\pydev\cx_Oracle-5.0.1>C:\python26\python setup.py install
running install
running build
running build_ext
building 'cx_Oracle' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Oracle\instantclient\sdk\include -IC:\p
ython26\include -IC:\python26\PC /Tccx_Oracle.c /Fobuild\temp.win32-2.6-11g\Release\cx_Oracle.obj -DBUILD_VERSION=5.0.1
cx_Oracle.c
c:\pydev\cx_oracle-5.0.1\StringVar.c(392) : warning C4018: '>' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\StringVar.c(417) : warning C4018: '>' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\ObjectVar.c(117) : warning C4018: '<' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\ObjectVar.c(134) : warning C4018: '<' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\Variable.c(331) : error C2036: 'void *' : unknown size
c:\pydev\cx_oracle-5.0.1\Variable.c(878) : warning C4244: '=' : conversion from 'sb2' to 'sb1', possible loss of data
c:\pydev\cx_oracle-5.0.1\Variable.c(914) : warning C4018: '<' : signed/unsigned mismatch
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
Does anyone have any idea how to fix this?
(I also may have an issue with that cl.exe file, I think I remember seeing this as a problem somewhere else, but I have four Windows machines which could have had issue there.).
----------------------------- EDIT -----------------------------
The reason I do not use the pre-compiled installer is because when I try to run the module I get the following:
Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "", line 1, in
ImportError: DLL load failed: The specified module could not be found.
I assume that means that it has not been properly installed. If someone can tell me what I did wrong here, that would also be a perfectly acceptable answer.
----------------------------- EDIT2 -----------------------------
I have retrieved all files from Oracle's Basic Client version 11.1.0.7. I have not tried installing a more substantial client. I am downloading one now.
%ORACLE_HOME%=C:\Oracle\instantclient\ #The directory where the above files have been extracted.
More information
- The current directory for the cx_Oracle's setup.py is C:\pydev\cx_Oracle-5.0.1
- The version of Python is 2.6.3
- The current directory for Python is C:\Python26 -- to access python 2.6 -> type py26 on the command line and it will map to C:\python26\python
Why don't you use a binary package like Windows Installer (Oracle 10g, Python 2.6)?
See http://cx-oracle.sourceforge.net/ for other binary packages
Addendum (as requested): you must ensure to use the cx_Oracle that :
- set ORACLE_HOME if this environment variable doesn't exist (see this Oracle FAQ)
- python can find
oraocci11.dll
for Oracle 11g, oraocci10.dll
for Oracle 10g or oraclient9.dll
for Oracle 9i by adding the folder (should be %ORACLE_HOME%/bin) where the DLL is in you PATH environment variable
- use the correct binary package (i.e. built for the right Python/Oracle versions)
You also need some type of Oracle client installed on your machine, since cx_Oracle is just a bridge between Python and the Oracle Client. Valid Oracle Clients include a full Oracle installation (like Standard or XE) or the Instant Client
From the README:
Please note that an Oracle client (or
server) installation is required in
order to use cx_Oracle. If you do not
require the tools that come with a
full client installation, it is
recommended to install the Instant
Client which is far easier to install.
I have not installed on Windows before, but you may have to set the ORACLE_HOME environment variable so that cx_Oracle knows where to look.
If you use Anaconda Python x64, things are easier:
conda install -c https://conda.anaconda.org/anaconda cx_oracle
(It will install the right Oracle client)
If you get the following error:
[Anaconda2] C:\Users\User>conda install -c https://conda.anaconda.org/anaconda c
x_oracle
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: .................
Package plan for installation in environment C:\Anaconda2:
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.19.1-py27_0 --> 4.0.5-py27_0
pip: 8.0.2-py27_0 --> 8.1.1-py27_0
pyyaml: 3.11-py27_2 --> 3.11-py27_3
setuptools: 19.6.2-py27_0 --> 20.3-py27_0
wheel: 0.26.0-py27_1 --> 0.29.0-py27_0
Proceed ([y]/n)? y
Unlinking packages ...
An unexpected error has occurred, please consider sending the | 0%
following traceback to the conda GitHub issue tracker at:
https://github.com/conda/conda/issues
Include the output of the command 'conda info' in your report.
Traceback (most recent call last):
File "C:\Anaconda2\Scripts\conda-script.py", line 4, in <module>
sys.exit(main())
File "C:\Anaconda2\lib\site-packages\conda\cli\main.py", line 173, in main
args_func(args, p)
File "C:\Anaconda2\lib\site-packages\conda\cli\main.py", line 180, in args_fun
c
args.func(args, p)
File "C:\Anaconda2\lib\site-packages\conda\cli\main_install.py", line 45, in e
xecute
install.install(args, parser, 'install')
File "C:\Anaconda2\lib\site-packages\conda\cli\install.py", line 423, in insta
ll
plan.execute_actions(actions, index, verbose=not args.quiet)
File "C:\Anaconda2\lib\site-packages\conda\plan.py", line 538, in execute_acti
ons
inst.execute_instructions(plan, index, verbose)
File "C:\Anaconda2\lib\site-packages\conda\instructions.py", line 148, in exec
ute_instructions
cmd(state, arg)
File "C:\Anaconda2\lib\site-packages\conda\instructions.py", line 95, in UNLIN
K_CMD
install.unlink(state['prefix'], arg)
File "C:\Anaconda2\lib\site-packages\conda\install.py", line 714, in unlink
os.unlink(meta_path)
WindowsError: [Error 5] Access is denied: 'C:\\Anaconda2\\conda-meta\\conda-3.19
.1-py27_0.json'
[Anaconda2] C:\Users\User>
Try running the Anaconda prompt as admin: