This discussion is archived
2 Replies Latest reply: Nov 2, 2009 10:05 AM by LaurenFoutz RSS

Python API setup problem on Windows

707995 Newbie
Currently Being Moderated
I just built the Python API for Berkeley DB XML 2.5.13. While it was pretty simple (I just had to enter "python setup.py build" and "python setup.py install" as explained in the README) I could not run any Python sample because of this error:
Traceback (most recent call last):
  File "C:\dbxml-2.5.13\dbxml\examples\python\basic\helloWorld.py", line 10, in <module>
    from dbxml import *
  File "C:\Python26\lib\site-packages\dbxml.py", line 25, in <module>
    _dbxml = swig_import_helper()
  File "C:\Python26\lib\site-packages\dbxml.py", line 24, in swig_import_helper
    return _mod
UnboundLocalError: local variable '_mod' referenced before assignment
As it turns out "python setup.py install" copies a few DLLs to the Python directory (C:\Python26 on my computer) but not zlib1.dll. As libdbxml25.dll depends on zlib1.dll the file must be copied manually. Then everything works fine.

The problem has been mentioned before by detonator413 (see Shortcoming in building procedure on Windows As it turns out it's also related to Python though.

Hope this helps anyone playing around with the Python API,
Boris
  • 1. Re: Python API setup problem on Windows
    Bogdan Coman Journeyer
    Currently Being Moderated
    Hi Boris,

    Thank you for reporting the bug! The bug is going to be fixed in the following patch set release.

    The workaround for now is to just copy zlib1.dll for 32-bit users, or zlibwapi.dll for 64 bit users, to the debug directory: \bin\debug

    Thanks,
    Bogdan Coman
  • 2. Re: Python API setup problem on Windows
    LaurenFoutz Journeyer
    Currently Being Moderated
    I believe you can edit the setup.py[.windows] files to do this automatically by changing the lines
     DATAFILES = [("", [os.path.join(dbxml_home,"../bin/debug/libdbxml25D.dll"),
                           os.path.join(dbxml_home,"../bin/debug/libdb48D.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xqilla22d.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xerces-c_3_0D.dll")])]
    to
     DATAFILES = [("", [os.path.join(dbxml_home,"../bin/debug/libdbxml25D.dll"),
                           os.path.join(dbxml_home,"build_windows/zlib1.dll"),
                           os.path.join(dbxml_home,"../bin/debug/libdb48D.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xqilla22d.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xerces-c_3_0D.dll")])]
    and
     DATAFILES = [("", [os.path.join(dbxml_home,"../bin/debug/libdbxml25.dll"),
                           os.path.join(dbxml_home,"../bin/debug/libdb48.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xqilla22.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xerces-c_3_0.dll")])]
    to
     DATAFILES = [("", [os.path.join(dbxml_home,"../bin/debug/libdbxml25.dll"),
                           os.path.join(dbxml_home,"build_windows/zlib1.dll"),
                           os.path.join(dbxml_home,"../bin/debug/libdb48.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xqilla22.dll"),
                           os.path.join(dbxml_home,"../bin/debug/xerces-c_3_0.dll")])]
    Let me know if that works please. (Also, us zlibwapi.dll on 64 bit systems).

    Lauren Foutz

    Edited by: LaurenFoutz on Nov 2, 2009 10:05 AM