cx_Oracle 5.0.4 + Python 3.1.2 + Oracle Instant Client 10.2.04; DLLLoad failed on import (Win/NT)

T

tormod

Hi,

I've tried countless times to build & install cx_Oracle on Python
3.1.2, and failed every time, so I'd like to ask someone for help.
I've included step-by-step (literally) description of my last try,
with so much detail I could, to help clarify things.

I can build without errors. I can install without errors. I fail to
import.

I'm using an NT box (os:Win7)

Downloaded Oracle Instant Client 10.2.0.4
instantclient-basic-win32-10.2.0.4.zip --> extracted to C:\TEMP
\ORAIC10\bin
instantclient-sdk-win32-10.2.0.4.zip --> extracted to C:\TEMP
\ORAIC10\sdk

Downloaded source code(cx_Oracle-5.0.4.tar.gz) from http://cx-oracle.sourceforge.net/
--> extracted to C:\TEMP\Python\cx_Oracle

Installed Python 3.1.2 --> C:\Python31
Installed MinGW 5.1.6 --> C:\MinGW


Startet command prompt:
cd C:\TEMP\Python\cx_Oracle
PATH=%PATH%;C:\Python31;C:\MinGW\bin;C:\TEMP\ORAIC10\bin
SET ORACLE_HOME=C:\TEMP\ORAIC10
SET LD_LIBRARY_PATH=C:\TEMP\ORAIC10\sdk\lib
python setup.py build -c mingw32
python setup.py install

start python:
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.


<output from build>
running build
running build_ext
building 'cx_Oracle' extension
creating build
creating build\temp.win32-3.1-10g
creating build\temp.win32-3.1-10g\Release
C:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\TEMP\ORAIC10\sdk
\include -I
C:\Python31\include -IC:\Python31\PC -c cx_Oracle.c -o build
\temp.win32-3.1-10g\
Release\cx_oracle.o -DBUILD_VERSION=5.0.4 -DWITH_UNICODE
writing build\temp.win32-3.1-10g\Release\cx_Oracle.def
creating build\lib.win32-3.1-10g
C:\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-3.1-10g
\Release\cx_
oracle.o build\temp.win32-3.1-10g\Release\cx_Oracle.def -LC:\TEMP
\ORAIC10\bin -L
C:\TEMP\ORAIC10 -LC:\TEMP\ORAIC10\oci\lib\msvc -LC:\TEMP\ORAIC10\sdk
\lib\msvc -L
C:\Python31\libs -LC:\Python31\PCbuild -loci -lpython31 -lmsvcr90 -o
build\lib.w
in32-3.1-10g\cx_Oracle.pyd
</output build>


<output from install>
running install
running build
running build_ext
running install_lib
copying build\lib.win32-3.1-10g\cx_Oracle.pyd -> C:\Python31\Lib\site-
packages
running install_data
running install_egg_info
Removing C:\Python31\Lib\site-packages\cx_Oracle-5.0.4-py3.1.egg-info
Writing C:\Python31\Lib\site-packages\cx_Oracle-5.0.4-py3.1.egg-info
</output install>

I've opened the cx_Oracle.pyd with Dependency Walker (http://
www.dependencywalker.com/) and DW reports it can't find: OCI.DLL,
PYTHON31.DLL, MSVCR90.DLL (why?)

Appreciate any help, even wildshots and 2 cents are welcome - I'll try
everything.

Cheers,
Tom
 
A

Alexander Gattin

Hello,

I've tried countless times to build & install cx_Oracle on Python
3.1.2, and failed every time, so I'd like to ask someone for help. ....
I've opened the cx_Oracle.pyd with Dependency Walker (http://
www.dependencywalker.com/) and DW reports it can't find: OCI.DLL,
PYTHON31.DLL, MSVCR90.DLL (why?)

Does Windows have anything like
LD_LIBRARY_PATH/SHLIB_PATH?
Appreciate any help, even wildshots and 2 cents are welcome - I'll try
everything.

please try starting python -d (--debug IIRC)
and then loading cx_Oracle manually
(>>> import cx_Oracle).

Usually it succeeds (sic!) but outputs a lot
of symbol errors. // Problem with Oracle libs
 
T

tormod

Does Windows have anything like
LD_LIBRARY_PATH/SHLIB_PATH?

No, isn't that only if I have an actual Oracle client installed (not
the instant client)?

But great tip, wasn't exactly the solution, but your question
triggered me to check the Windows environment variables*. I included
env. variable name PATH and the value ;C:\Python31;C:\MinGW\bin;C:\TEMP
\ORAIC10\bin.
Only thing I set manually in the command prompt was: SET ORACLE_HOME=C:
\TEMP\ORAIC10 , before the build.

*=I checked the setup.py script which says:
userOracleHome = os.environ.get("ORACLE_HOME")
Checking in Visual Basic::environ("path") only included info from the
Windows env. variables, and not the ones I set via the command prompt
with PATH=%PATH%;... so I reckon if it applies to VB it also does for
os.environ

I can now import without errors!

Thanks Alexander for putting me in the right direction.
 
H

Hans Mulder

Yes and no. Windows uses PATH both for finding execuables and for
finding DLLs. So if there's a DLL Windows cannot find, you need to
add the folder containing that DLL to your PATH variable.
No, isn't that only if I have an actual Oracle client installed (not
the instant client)?

Whether you use the instant client or an actual Oracle client is not
the issue. You may or may not need LD_LIBRARY_PATH either way.

When you import cx_Oracle on Linux, it loads a file named cx_Oracle.so
which in turn loads two files named libclntsh.so and libnnz10.so.
These two files are part of the Oracle client installation. The dynamic
loader has a list of directories where it tries to find these files;
if they aren't there, then the import of cx_Oracle will fail. In that
case, you need to set LD_LIBRARY_PATH to the directory containing them
(or talk your sysadmin into adding this directory to the default path.
He'd do that by adding the directory to /etc/ld.so.conf and running
ldconfig).

Hope this helps,

-- HansM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top