Cx_oracle Install Windows

Posted By admin On 19.09.19

Here's what worked for me. My Python and Oracle versions are slightly different from yours, but the same approach should apply. Just make sure the cxOracle binary installer version matches your Oracle client and Python versions.

Windows

My versions:. Python 2.7. Oracle Instant Client 11G R2. cxOracle 5.0.4 (Unicode, Python 2.7, Oracle 11G). Windows XP SP3 Steps:.

Download the Oracle Instant Client package. I used instantclient-basic-win32-11.2.0.1.0.zip.

Your email is never published nor shared. You're allow to say what you want.

Unzip it to C: your path to instantclient112. Download and run the cxOracle binary installer.

I used cxOracle-5.0.4-11g-unicode.win32-py2.7.msi. I installed it for all users and pointed it to the Python 2.7 location it found in the registry. Set the ORACLEHOME and PATH environment variables via a batch script or whatever mechanism makes sense in your app context, so that they point to the Oracle Instant Client directory. See oraclepython.bat source below. I'm sure there must be a more elegant solution for this, but I wanted to limit my system-wide changes as much as possible. Make sure you put the targeted Oracle Instant Client directory at the beginning of the PATH (or at least ahead of any other Oracle client directories). Right now, I'm only doing command-line stuff so I just run oraclepython.bat in the shell before running any programs that require cxOracle.

Run regedit and check to see if there's an NLSLANG key set at HKEYLOCALMACHINE SOFTWARE ORACLE. If so, rename the key (I changed it to NLSLANGOLD) or unset it. This key should only be used as the default NLSLANG value for Oracle 7 client, so it's safe to remove it unless you happen to be using Oracle 7 client somewhere else.

As always, be sure to backup your registry before making changes. Now, you should be able to import cxOracle in your Python program. See the oracletest.py source below. Note that I had to set the connection and SQL strings to Unicode for my version of cxOracle. Source: oraclepython.bat @echo off set ORACLEHOME=C: your path to instantclient112 set PATH=%ORACLEHOME%;%PATH% Source: oracletest.py import cxOracle connstr = u'user/password@host:port/service' conn = cxOracle.connect(connstr) c = conn.cursor c.execute(u'select yourcol1, yourcol2 from yourtable') for row in c: print row0, '-', row1 conn.close Possible Issues:. 'ORA-12705: Cannot access NLS data files or invalid environment specified' - I ran into this before I made the NLSLANG registry change. 'TypeError: argument 1 must be unicode, not str' - if you need to set the connection string to Unicode.

Python cx_oracle install windows

'TypeError: expecting None or a string' - if you need to set the SQL string to Unicode. 'ImportError: DLL load failed: The specified procedure could not be found.'

Python Cx_oracle Install Windows

- may indicate that cxOracle can't find the appropriate Oracle client DLL.

Let's say that your custom channel is located in the following directory: N: conda channel. Then we would expect to see the following in this directory (1) the win-64 directory (2) the index files inside, in this case the directory N: conda channel win-64, of repodata.json and repodata.json.bz2 (3) any packages that you have added to your channel. A search on this channel for the scipy package, ignoring all other channels, would look like this conda search -c file://N: conda channel -override-channels scipy Did you add the scipy package into your custom channel? If you did, then did you run conda index on that directory? I'm a little confused by your directory structure but, if your channel is machine C channel, then what happens when you do dir machine C channel? If you are trying to search for a conda package in a local directory (not on UNC), the following two approaches worked for me.

Navigate to the drive containing the package and try conda search -c file://folderpath/channel -override-channels. the better way is to drop the file flag which allows you to search from any drive. Type conda search -c Drive://folderpath/channel -override-channels thus if you are searching from D: drive you would type this as conda search -c D://folderpath/channel -override-channels.