py2exe: problem including libxml2

Discussion in 'Python' started by Rene Olsthoorn, Dec 4, 2003.

  1. Dear readers,

    py2exe has a problem including libxml2. Not at building time, but at
    runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has
    the problem? (and can you drop me your setup.py scipt, please).

    Thanks in advance,
    Rene O.
     
    Rene Olsthoorn, Dec 4, 2003
    #1
    1. Advertising

  2. "Rene Olsthoorn" <> wrote in
    news:3fcf581e$0$200$4all.nl:

    > py2exe has a problem including libxml2. Not at building time, but at
    > runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has
    > the problem? (and can you drop me your setup.py scipt, please).


    i have no project using that lib, so i cant tell from experience.
    but did you check if the lib is copied to the dist dir?
    if its not copied, you may need to use the data_files option altough the
    dependecies for taht lib have to be tracked manually
    or the --packages or --force-imports option may help, if you load the xml
    module in advance

    you should probably mention which python and py2exe version you used as
    well as the module you import that does not work. the 0.5 version has a
    slightly different output than the older ones.

    chris

    --
    Chris <>
     
    Chris Liechti, Dec 4, 2003
    #2
    1. Advertising

  3. "Rene Olsthoorn" <> wrote in message
    news:3fcf581e$0$200$4all.nl...
    > Dear readers,
    >
    > py2exe has a problem including libxml2. Not at building time, but at
    > runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has
    > the problem? (and can you drop me your setup.py scipt, please).
    >


    Perhaps you hit the same problem I did when using libxml2 and libxslt in a
    service created by p2exe.

    Here are notes from my project diary (these notes are meant for my client to
    reconcile my bill vs. what I did)
    -----
    The service builds, I can install it, but get an error when I run it:

    The instance's SvcRun() method failed
    File "win32serviceutil.pyo", line 663, in SvcRun
    File "UMXWIN32SVC.pyo", line 41, in SvcDoRun
    File "Rose\WebServer\UMXMServer.pyo", line 53, in ?
    File "Rose\WebServer\umx_handler.pyo", line 16, in ?
    File "Rose\WebServer\HTTPHandler.pyo", line 95, in ?
    File "Rose\WebServer\XMLProcessor.pyo", line 34, in ?

    exceptions.ImportError: dynamic module does not define init
    function (initlibxslt)

    This says that the service cannot import the libxslt module for some reason.

    I built a test script that py2exe runs in console mode, it also fails in the
    same way.

    I think libxml is using some kind of dynamic import mechanism, we need to
    work around.

    Aha, figured it out. example problem with libxml2.

    libxml2.py is a module that imports libxml2mod.pyd which imports libxml2.dll

    But, py2exe creates a default path like this:

    c:\\temp\\rose, c:\\temp\\rose\\library.zip

    This means that python tries to import from the directory first, before
    importing from library.zip. So, python imports libxml2.dll, not libxml2.py

    My workaround is to reverse the order of the imports in the startup script:

    zipfile = sys.path[-1]
    sys.path.insert(0,zipfile)
     
    Brad Clements, Dec 5, 2003
    #3
  4. "Brad Clements" <> writes:

    > "Rene Olsthoorn" <> wrote in message
    > news:3fcf581e$0$200$4all.nl...
    >> Dear readers,
    >>
    >> py2exe has a problem including libxml2. Not at building time, but at
    >> runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has
    >> the problem? (and can you drop me your setup.py scipt, please).
    >>

    >
    > Perhaps you hit the same problem I did when using libxml2 and libxslt in a
    > service created by p2exe.
    >
    > Here are notes from my project diary (these notes are meant for my client to
    > reconcile my bill vs. what I did)
    > -----
    > The service builds, I can install it, but get an error when I run it:
    >
    > The instance's SvcRun() method failed
    > File "win32serviceutil.pyo", line 663, in SvcRun
    > File "UMXWIN32SVC.pyo", line 41, in SvcDoRun
    > File "Rose\WebServer\UMXMServer.pyo", line 53, in ?
    > File "Rose\WebServer\umx_handler.pyo", line 16, in ?
    > File "Rose\WebServer\HTTPHandler.pyo", line 95, in ?
    > File "Rose\WebServer\XMLProcessor.pyo", line 34, in ?
    >
    > exceptions.ImportError: dynamic module does not define init
    > function (initlibxslt)
    >
    > This says that the service cannot import the libxslt module for some reason.
    >
    > I built a test script that py2exe runs in console mode, it also fails in the
    > same way.
    >
    > I think libxml is using some kind of dynamic import mechanism, we need to
    > work around.
    >
    > Aha, figured it out. example problem with libxml2.
    >
    > libxml2.py is a module that imports libxml2mod.pyd which imports libxml2.dll
    >
    > But, py2exe creates a default path like this:
    >
    > c:\\temp\\rose, c:\\temp\\rose\\library.zip
    >
    > This means that python tries to import from the directory first, before
    > importing from library.zip. So, python imports libxml2.dll, not libxml2.py
    >
    > My workaround is to reverse the order of the imports in the startup script:
    >
    > zipfile = sys.path[-1]
    > sys.path.insert(0,zipfile)


    Which version of py2exe are you using, and what is this libxml2?

    IIRC, in the latest version py2exe doesn't put the executable's
    directory on the path anymore, but file names like libxml2.py,
    libxml2.pyd, and libxml2.dll all at the same time have the potential to
    confuse it!

    Thomas
     
    Thomas Heller, Dec 5, 2003
    #4
  5. I used a cvs checking. py2exe/__init__.py has this:

    __version__ = "0.4.0"



    --
    Novell DeveloperNet Sysop #5

    _
    "Thomas Heller" <> wrote in message
    news:...
    > "Brad Clements" <> writes:
    >
    > > "Rene Olsthoorn" <> wrote in message
    > > news:3fcf581e$0$200$4all.nl...
    > >> Dear readers,
    > >>
    > >> py2exe has a problem including libxml2. Not at building time, but at
    > >> runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT

    has
    > >> the problem? (and can you drop me your setup.py scipt, please).
    > >>

    > >
    > > Perhaps you hit the same problem I did when using libxml2 and libxslt in

    a
    > > service created by p2exe.
    > >
    > > Here are notes from my project diary (these notes are meant for my

    client to
    > > reconcile my bill vs. what I did)
    > > -----
    > > The service builds, I can install it, but get an error when I run it:
    > >
    > > The instance's SvcRun() method failed
    > > File "win32serviceutil.pyo", line 663, in SvcRun
    > > File "UMXWIN32SVC.pyo", line 41, in SvcDoRun
    > > File "Rose\WebServer\UMXMServer.pyo", line 53, in ?
    > > File "Rose\WebServer\umx_handler.pyo", line 16, in ?
    > > File "Rose\WebServer\HTTPHandler.pyo", line 95, in ?
    > > File "Rose\WebServer\XMLProcessor.pyo", line 34, in ?
    > >
    > > exceptions.ImportError: dynamic module does not define init
    > > function (initlibxslt)
    > >
    > > This says that the service cannot import the libxslt module for some

    reason.
    > >
    > > I built a test script that py2exe runs in console mode, it also fails in

    the
    > > same way.
    > >
    > > I think libxml is using some kind of dynamic import mechanism, we need

    to
    > > work around.
    > >
    > > Aha, figured it out. example problem with libxml2.
    > >
    > > libxml2.py is a module that imports libxml2mod.pyd which imports

    libxml2.dll
    > >
    > > But, py2exe creates a default path like this:
    > >
    > > c:\\temp\\rose, c:\\temp\\rose\\library.zip
    > >
    > > This means that python tries to import from the directory first, before
    > > importing from library.zip. So, python imports libxml2.dll, not

    libxml2.py
    > >
    > > My workaround is to reverse the order of the imports in the startup

    script:
    > >
    > > zipfile = sys.path[-1]
    > > sys.path.insert(0,zipfile)

    >
    > Which version of py2exe are you using, and what is this libxml2?
    >
    > IIRC, in the latest version py2exe doesn't put the executable's
    > directory on the path anymore, but file names like libxml2.py,
    > libxml2.pyd, and libxml2.dll all at the same time have the potential to
    > confuse it!
    >
    > Thomas
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
     
    Brad Clements, Dec 8, 2003
    #5
  6. Brad, Thomas,

    Thanks for your help.
    Brad, you were right. It is a same name problem.

    The sys.path trick that Brad uses is good.
    If that does not work try the following:
    Go to your Python 2.3 site-packages directory. Locate the file libxml2.py
    and copy it to libxml2py.py
    In your code use:
    import libxml2py as libxml2
    Then, the exe generated by py2exe correctly runs.

    Thomas, LibXML is a very fast XML parser. It has python bindings.
    http://xmlsoft.org/python.html

    Greets,
    Rene Olsthoorn.



    "Thomas Heller" <> schreef in bericht
    news:...
    > "Brad Clements" <> writes:
    >
    > > "Rene Olsthoorn" <> wrote in message
    > > news:3fcf581e$0$200$4all.nl...
    > >> Dear readers,
    > >>
    > >> py2exe has a problem including libxml2. Not at building time, but at
    > >> runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT

    has
    > >> the problem? (and can you drop me your setup.py scipt, please).
    > >>

    > >
    > > Perhaps you hit the same problem I did when using libxml2 and libxslt in

    a
    > > service created by p2exe.
    > >
    > > Here are notes from my project diary (these notes are meant for my

    client to
    > > reconcile my bill vs. what I did)
    > > -----
    > > The service builds, I can install it, but get an error when I run it:
    > >
    > > The instance's SvcRun() method failed
    > > File "win32serviceutil.pyo", line 663, in SvcRun
    > > File "UMXWIN32SVC.pyo", line 41, in SvcDoRun
    > > File "Rose\WebServer\UMXMServer.pyo", line 53, in ?
    > > File "Rose\WebServer\umx_handler.pyo", line 16, in ?
    > > File "Rose\WebServer\HTTPHandler.pyo", line 95, in ?
    > > File "Rose\WebServer\XMLProcessor.pyo", line 34, in ?
    > >
    > > exceptions.ImportError: dynamic module does not define init
    > > function (initlibxslt)
    > >
    > > This says that the service cannot import the libxslt module for some

    reason.
    > >
    > > I built a test script that py2exe runs in console mode, it also fails in

    the
    > > same way.
    > >
    > > I think libxml is using some kind of dynamic import mechanism, we need

    to
    > > work around.
    > >
    > > Aha, figured it out. example problem with libxml2.
    > >
    > > libxml2.py is a module that imports libxml2mod.pyd which imports

    libxml2.dll
    > >
    > > But, py2exe creates a default path like this:
    > >
    > > c:\\temp\\rose, c:\\temp\\rose\\library.zip
    > >
    > > This means that python tries to import from the directory first, before
    > > importing from library.zip. So, python imports libxml2.dll, not

    libxml2.py
    > >
    > > My workaround is to reverse the order of the imports in the startup

    script:
    > >
    > > zipfile = sys.path[-1]
    > > sys.path.insert(0,zipfile)

    >
    > Which version of py2exe are you using, and what is this libxml2?
    >
    > IIRC, in the latest version py2exe doesn't put the executable's
    > directory on the path anymore, but file names like libxml2.py,
    > libxml2.pyd, and libxml2.dll all at the same time have the potential to
    > confuse it!
    >
    > Thomas
     
    Rene Olsthoorn, Dec 8, 2003
    #6
  7. Brad, Thomas,

    Thanks for your help.
    Brad, you were right. It is a same name problem.
    The sys.path trick that Brad uses is good.
    If that does not work try the following:

    Go to your Python 2.3 site-packages directory. Locate the file libxml2.py
    and copy it to libxml2py.py In your code use: import libxml2py as libxml2
    Then, the exe generated by py2exe correctly runs.
    Thomas, LibXML is a very fast XML parser. It has python bindings.
    http://xmlsoft.org/python.html

    Greets,
    Rene Olsthoorn.

    "Thomas Heller" <> schreef in bericht
    news:...
    > "Brad Clements" <> writes:
    >
    > > "Rene Olsthoorn" <> wrote in message
    > > news:3fcf581e$0$200$4all.nl...
    > >> Dear readers,
    > >>
    > >> py2exe has a problem including libxml2. Not at building time, but at
    > >> runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT

    has
    > >> the problem? (and can you drop me your setup.py scipt, please).
    > >>

    > >
    > > Perhaps you hit the same problem I did when using libxml2 and libxslt in

    a
    > > service created by p2exe.
    > >
    > > Here are notes from my project diary (these notes are meant for my

    client to
    > > reconcile my bill vs. what I did)
    > > -----
    > > The service builds, I can install it, but get an error when I run it:
    > >
    > > The instance's SvcRun() method failed
    > > File "win32serviceutil.pyo", line 663, in SvcRun
    > > File "UMXWIN32SVC.pyo", line 41, in SvcDoRun
    > > File "Rose\WebServer\UMXMServer.pyo", line 53, in ?
    > > File "Rose\WebServer\umx_handler.pyo", line 16, in ?
    > > File "Rose\WebServer\HTTPHandler.pyo", line 95, in ?
    > > File "Rose\WebServer\XMLProcessor.pyo", line 34, in ?
    > >
    > > exceptions.ImportError: dynamic module does not define init
    > > function (initlibxslt)
    > >
    > > This says that the service cannot import the libxslt module for some

    reason.
    > >
    > > I built a test script that py2exe runs in console mode, it also fails in

    the
    > > same way.
    > >
    > > I think libxml is using some kind of dynamic import mechanism, we need

    to
    > > work around.
    > >
    > > Aha, figured it out. example problem with libxml2.
    > >
    > > libxml2.py is a module that imports libxml2mod.pyd which imports

    libxml2.dll
    > >
    > > But, py2exe creates a default path like this:
    > >
    > > c:\\temp\\rose, c:\\temp\\rose\\library.zip
    > >
    > > This means that python tries to import from the directory first, before
    > > importing from library.zip. So, python imports libxml2.dll, not

    libxml2.py
    > >
    > > My workaround is to reverse the order of the imports in the startup

    script:
    > >
    > > zipfile = sys.path[-1]
    > > sys.path.insert(0,zipfile)

    >
    > Which version of py2exe are you using, and what is this libxml2?
    >
    > IIRC, in the latest version py2exe doesn't put the executable's
    > directory on the path anymore, but file names like libxml2.py,
    > libxml2.pyd, and libxml2.dll all at the same time have the potential to
    > confuse it!
    >
    > Thomas
     
    Rene Olsthoorn, Dec 17, 2003
    #7
    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. F. GEIGER
    Replies:
    0
    Views:
    951
    F. GEIGER
    Aug 16, 2004
  2. Mr BigSmoke

    including directories with py2exe

    Mr BigSmoke, Feb 26, 2006, in forum: Python
    Replies:
    1
    Views:
    315
    Larry Bates
    Feb 27, 2006
  3. python
    Replies:
    3
    Views:
    1,886
    Simon Brunning
    May 22, 2006
  4. Chris Spencer

    Re: [Py2exe-users] py2exe 0.6.9 released

    Chris Spencer, Nov 17, 2008, in forum: Python
    Replies:
    3
    Views:
    599
    Pascal
    Dec 8, 2008
  5. Mark Hammond

    RE: [Py2exe-users] py2exe 0.6.9 released

    Mark Hammond, Nov 17, 2008, in forum: Python
    Replies:
    0
    Views:
    479
    Mark Hammond
    Nov 17, 2008
Loading...

Share This Page