installing cx_Oracle

Discussion in 'Python' started by Rodrigo Daunaravicius, Jun 4, 2004.

  1. I can't get this configuration working:
    cx_Oracle 4.0.1
    Oracle 8.0.6
    Python 2.3.3
    Win NT4.0 SP6fc

    My first shot at the problem was just running the installation thingie
    pre-built for win32/python2.3/Oracle8i. It installed with no complaints but
    I can't import the module (can't find OCIEnvCreate entry point in the
    OCI.dll library).
    This version was built for Oracle 8.1.7, so I figure that must be the
    problem.

    Then I downloaded the sources, but can't build them. After a fair amount of
    fiddling with setup.py and some of the C header files to compensate for the
    unusual file structure of my Oracle Client installation and for the use of
    the gcc compilator instead of Visual Studio, I got stuck at this point:

    :>python setup.py -build -c mingw32 install
    :running build
    :running build_ext
    :building 'cx_Oracle' extension
    :D:\minGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Id:\orant\oci80\include
    :-Id:\orant\rdbms80\demo -ID:\Python23\include -ID:\Python23\PC -c
    :cx_Oracle.c -o build\temp.win32-2.3\Release\cx_oracle.o
    :"-DBUILD_TIME="""June 04, 2004 16:42:10"""
    :In file included from cx_Oracle.c:63:
    :Environment.c: In function `Environment_New':
    :Environment.c:78: warning: implicit declaration of function `OCIEnvCreate'
    :[follows a bunch of declaration errors for anything that's named
    :OCIwhatever]


    According to the Oracle Docs, "OCIEnvCreate creates and initializes an
    environment for OCI functions to work under".

    So my uneducated guess is that this OCIEnvCreate function is not present in
    Oracle 8.0.6, but I can't find anything in the docs that hints to it.


    1. Is there a way around this OCIEnvCrete problem?

    2. Is there an alternative to cx_Oracle that works out of the box with
    Oracle 8.0.6? (tryed DCOracle2, but couldn't make it work with Python2.3
    AND without Zope)

    3. Should I give up cx_Oracle and stick with ODBC?

    4. Should I give up python and stick with Access VBA? (sorry, bad joke)



    Any insight would be helpful (even another forum where I could forward this
    specific question).

    Thanks in advance,
    Rodrigo Daunaravicius
    Rodrigo Daunaravicius, Jun 4, 2004
    #1
    1. Advertising

  2. Rodrigo Daunaravicius

    David Fraser Guest

    Rodrigo Daunaravicius wrote:

    > 3. Should I give up cx_Oracle and stick with ODBC?
    >
    > 4. Should I give up python and stick with Access VBA? (sorry, bad joke)


    Sorry this doesn't answer your questions, but since you're on Windows,
    you may want to use one of the ADO wrappers for Python ... if you can't
    get this working

    David
    David Fraser, Jun 4, 2004
    #2
    1. Advertising

  3. Rodrigo Daunaravicius wrote:
    > I can't get this configuration working:
    > cx_Oracle 4.0.1
    > Oracle 8.0.6
    > Python 2.3.3
    > Win NT4.0 SP6fc
    >
    > My first shot at the problem was just running the installation thingie
    > pre-built for win32/python2.3/Oracle8i. It installed with no complaints but
    > I can't import the module (can't find OCIEnvCreate entry point in the
    > OCI.dll library).
    > This version was built for Oracle 8.1.7, so I figure that must be the
    > problem.
    >
    > Then I downloaded the sources, but can't build them. After a fair amount of
    > fiddling with setup.py and some of the C header files to compensate for the
    > unusual file structure of my Oracle Client installation and for the use of
    > the gcc compilator instead of Visual Studio, I got stuck at this point:
    >
    > :>python setup.py -build -c mingw32 install
    > :running build
    > :running build_ext
    > :building 'cx_Oracle' extension
    > :D:\minGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Id:\orant\oci80\include
    > :-Id:\orant\rdbms80\demo -ID:\Python23\include -ID:\Python23\PC -c
    > :cx_Oracle.c -o build\temp.win32-2.3\Release\cx_oracle.o
    > :"-DBUILD_TIME="""June 04, 2004 16:42:10"""
    > :In file included from cx_Oracle.c:63:
    > :Environment.c: In function `Environment_New':
    > :Environment.c:78: warning: implicit declaration of function `OCIEnvCreate'
    > :[follows a bunch of declaration errors for anything that's named
    > :OCIwhatever]
    >
    >
    > According to the Oracle Docs, "OCIEnvCreate creates and initializes an
    > environment for OCI functions to work under".
    >
    > So my uneducated guess is that this OCIEnvCreate function is not present in
    > Oracle 8.0.6, but I can't find anything in the docs that hints to it.
    >
    >
    > 1. Is there a way around this OCIEnvCrete problem?
    >
    > 2. Is there an alternative to cx_Oracle that works out of the box with
    > Oracle 8.0.6? (tryed DCOracle2, but couldn't make it work with Python2.3
    > AND without Zope)
    >
    > 3. Should I give up cx_Oracle and stick with ODBC?
    >
    > 4. Should I give up python and stick with Access VBA? (sorry, bad joke)
    >
    >
    >
    > Any insight would be helpful (even another forum where I could forward this
    > specific question).
    >
    > Thanks in advance,
    > Rodrigo Daunaravicius


    I had the same problem trying to connect to an Oracle 8.0.5 database.
    The cx_Oracle binary was compiled for Oracle 8i/9i, and it didn't work
    with the Oracle 8.0.5 OCI (Oracle Call Interface). Neither did the
    source (I think it's designed to connect to an 8i/9i OCI, different from
    an 8.0 OCI).


    The solution (for me):

    I installed an Oracle 8i client in another ORACLE_HOME in the same
    Windows box, and modified the PATH environment variable to put the BIN
    directory of the (new) Oracle 8i ORACLE_HOME before the BIN directory of
    the (old) Oracle 8.0.5 ORACLE_HOME. So, when the cx_Oracle binary looks
    for the OCI, it finds the Oracle8i installation and connects to the
    database.

    From your post, it's not clear to me if you have an Oracle 8.0.6 server
    in your machine, or not. Maybe an Oracle server installation does not
    like the Oracle 8i client installation and the PATH modification that I
    suggest.

    Hope this helps

    Aurelio
    Aurelio Martin, Jun 4, 2004
    #3
  4. Rodrigo Daunaravicius

    David Fraser Guest

    Rodrigo Daunaravicius wrote:
    > According to the Oracle Docs, "OCIEnvCreate creates and initializes an
    > environment for OCI functions to work under".
    >
    > So my uneducated guess is that this OCIEnvCreate function is not present in
    > Oracle 8.0.6, but I can't find anything in the docs that hints to it.
    >
    >
    > 1. Is there a way around this OCIEnvCrete problem?


    From
    http://www.csee.umbc.edu/help/oracle8/server.815/a67846/oci_func.htm#543147
    > OCIEnvCreate()
    >
    > This call creates an environment for all the OCI calls using the modes specified by the user. This call should be invoked before any other OCI call and should be used instead of the OCIInitialize() and OCIEnvInit() calls. OCIInitialize() and OCIEnvInit() calls will be supported for backward compatibility.
    >


    If you really need to get it working with 8.0.x libraries, you could try
    converting the call to OCIInitialize() and OCIEnvInit() calls.
    You'll need to replace OCITerminate with OCIHandleFree.
    In my experience these are the two main changes between 8.0.x and 8.1
    You might find some help from the cx_Oracle authors, but the oracle docs
    are fairly good.
    Here is some code from a C++ database class that supports either
    (tryimportOCIProc and importedOCIProc and importOCIProc are macros that
    do dynamic function resolving, you should get the general idea)

    tryimportOCIProc(OCIEnvCreate, sword, (OCIEnv **envp, ub4 mode, dvoid
    *ctxp,
    dvoid *(*malocfp)(dvoid *ctxp, size_t size),
    dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize),
    void (*mfreefp)(dvoid *ctxp, dvoid *memptr),
    size_t xtramem_sz, dvoid **usrmempp));

    if (!importedOCIProc(OCIEnvCreate))
    {
    importOCIProc(OCIInitialize, sword, (ub4 mode, CONST dvoid *ctxp,
    CONST dvoid *(*malocfp)(dvoid *ctxp, size_t size),
    CONST dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr,size_t newsize),
    CONST void (*mfreefp)(dvoid *ctxp,dvoid *memptr)));
    importOCIProc(OCIEnvInit, sword, (OCIEnv **envhpp, ub4 mode,
    size_t xtramemsz, dvoid **usrmempp));

    if (envhp == 0)
    {
    OCIInitialize(OCI_THREADED, 0, 0, 0, 0);
    OCIEnvInit(&envhp, OCI_DEFAULT, 100, &testmem);
    }
    // AfxMessageBox("Using OCI 8.0",MB_OK);
    }
    else
    {
    if (envhp == 0)
    OCIEnvCreate(&envhp, OCI_THREADED, 0, 0, 0, 0, 0, 0);
    }
    David Fraser, Jun 4, 2004
    #4
  5. On Fri, 04 Jun 2004 22:11:06 +0200, David Fraser wrote:

    > If you really need to get it working with 8.0.x libraries, you could try
    > converting the call to OCIInitialize() and OCIEnvInit() calls.
    > You'll need to replace OCITerminate with OCIHandleFree.
    > In my experience these are the two main changes between 8.0.x and 8.1
    > You might find some help from the cx_Oracle authors, but the oracle docs
    > are fairly good.


    Thanks, David. I successfully replaced the OCIEnvCreate() call, but still
    had problems with OCILobCreateTemporary(), OCILobFreeTemporary(),
    OCIUserCallbackRegister(), OCIUserCallbackGet(), OCI_UCBTYPE_ENTRY,
    OCI_UCBTYPE_EXIT and OCI_UCBTYPE_REPLACE. This amount of patchwork from my
    inexperienced hands would be asking for trouble, even if I could get it
    compiled.
    An 8i installation, as Aurelio suggested, is unfortunately not an option.
    I'm now looking into ADO. I think it can fit the bill for my current
    project, though I'd prefer to use the python DB API 2.0.

    Rodrigo
    Rodrigo Daunaravicius, Jun 7, 2004
    #5
  6. Rodrigo Daunaravicius

    David Fraser Guest

    Rodrigo Daunaravicius wrote:
    > On Fri, 04 Jun 2004 22:11:06 +0200, David Fraser wrote:
    >
    >
    >>If you really need to get it working with 8.0.x libraries, you could try
    >>converting the call to OCIInitialize() and OCIEnvInit() calls.
    >>You'll need to replace OCITerminate with OCIHandleFree.
    >>In my experience these are the two main changes between 8.0.x and 8.1
    >>You might find some help from the cx_Oracle authors, but the oracle docs
    >>are fairly good.

    >
    >
    > Thanks, David. I successfully replaced the OCIEnvCreate() call, but still
    > had problems with OCILobCreateTemporary(), OCILobFreeTemporary(),
    > OCIUserCallbackRegister(), OCIUserCallbackGet(), OCI_UCBTYPE_ENTRY,
    > OCI_UCBTYPE_EXIT and OCI_UCBTYPE_REPLACE. This amount of patchwork from my
    > inexperienced hands would be asking for trouble, even if I could get it
    > compiled.


    Oh well, it was worth a try...

    > An 8i installation, as Aurelio suggested, is unfortunately not an option.
    > I'm now looking into ADO. I think it can fit the bill for my current
    > project, though I'd prefer to use the python DB API 2.0.


    Aha! But you can... there are at least two DB API wrappers for ADO:
    http://pyado.sourceforge.net/
    http://adodbapi.sourceforge.net/

    So your code remains DB-API compatible, and portable to other drivers,
    but gets to use ADO and support any database supported by that...

    David
    David Fraser, Jun 8, 2004
    #6
  7. > An 8i installation, as Aurelio suggested, is unfortunately not an option.

    You still haven't told us why; are you running an 8.0.6 server
    on that box? I reckon you could install a minimal more recent
    oracle client, *not* put it on your global path, but simply stick
    it at the beginning of your python script path *before* importing
    cx_oracle.

    Oracle instant client weights about 30Mb on windows:
    http://otn.oracle.com/tech/oci/instantclient/instantclient.html
    (warning: this probably requires an OTN registration)

    HTH,

    Bernard.
    =?ISO-8859-1?Q?Bernard_Delm=E9e?=, Jun 8, 2004
    #7
  8. On Tue, 08 Jun 2004 12:42:00 +0200, David Fraser wrote:

    > Aha! But you can... there are at least two DB API wrappers for ADO:
    > http://pyado.sourceforge.net/
    > http://adodbapi.sourceforge.net/


    Yes! I imagined such a wrapper might exist and found adodbapi. It seems
    quite satisfactory. I'll have a look at pyado too. Thanks again, David.

    Rodrigo
    Rodrigo Daunaravicius, Jun 9, 2004
    #8
  9. On Tue, 08 Jun 2004 21:02:45 +0200, Bernard Delmée wrote:

    >> An 8i installation, as Aurelio suggested, is unfortunately not an option.

    >
    > You still haven't told us why; are you running an 8.0.6 server
    > on that box? I reckon you could install a minimal more recent
    > oracle client, *not* put it on your global path, but simply stick
    > it at the beginning of your python script path *before* importing
    > cx_oracle.
    >
    > Oracle instant client weights about 30Mb on windows:
    > http://otn.oracle.com/tech/oci/instantclient/instantclient.html
    > (warning: this probably requires an OTN registration)
    >
    > HTH,
    >
    > Bernard.


    My only problem was licence. I wasn't aware of this Instant Client, but I'm
    definitely giving it a try. Thanks Bernard.

    Rodrigo
    Rodrigo Daunaravicius, Jun 9, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Glenn Stauffer

    cx_Oracle & prepared statements

    Glenn Stauffer, Aug 16, 2003, in forum: Python
    Replies:
    0
    Views:
    835
    Glenn Stauffer
    Aug 16, 2003
  2. GrayGeek

    import cx_Oracle

    GrayGeek, Nov 1, 2003, in forum: Python
    Replies:
    12
    Views:
    1,095
    GrayGeek
    Nov 7, 2003
  3. Carl K

    installing cx_Oracle.

    Carl K, May 24, 2007, in forum: Python
    Replies:
    8
    Views:
    4,478
    Carsten Haese
    May 24, 2007
  4. Doug Phillips

    RE: installing cx_Oracle.

    Doug Phillips, May 24, 2007, in forum: Python
    Replies:
    1
    Views:
    339
    Charles Sanders
    May 25, 2007
  5. AMC

    Error installing cx_Oracle

    AMC, Sep 22, 2010, in forum: Python
    Replies:
    1
    Views:
    1,029
    James Mills
    Sep 23, 2010
Loading...

Share This Page