472,337 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

py2exe: problem including libxml2

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.
Jul 18 '05 #1
5 3921
"Rene Olsthoorn" <ro*@post.com> wrote in
news:3f*********************@news.xs4all.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 <cl******@gmx.net>

Jul 18 '05 #2
"Rene Olsthoorn" <ro*@post.com> wrote in message
news:3f*********************@news.xs4all.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)


Jul 18 '05 #3
I used a cvs checking. py2exe/__init__.py has this:

__version__ = "0.4.0"

--
Novell DeveloperNet Sysop #5

_
"Thomas Heller" <th*****@python.net> wrote in message
news:fz**********@python.net...
"Brad Clements" <bk*@Murkworks.com> writes:
"Rene Olsthoorn" <ro*@post.com> wrote in message
news:3f*********************@news.xs4all.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



Jul 18 '05 #4
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" <th*****@python.net> schreef in bericht
news:fz**********@python.net...
"Brad Clements" <bk*@Murkworks.com> writes:
"Rene Olsthoorn" <ro*@post.com> wrote in message
news:3f*********************@news.xs4all.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

Jul 18 '05 #5
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" <th*****@python.net> schreef in bericht
news:fz**********@python.net...
"Brad Clements" <bk*@Murkworks.com> writes:
"Rene Olsthoorn" <ro*@post.com> wrote in message
news:3f*********************@news.xs4all.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

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Peuser | last post by:
Hi, I should like to make a distribution (using Tkinter), with standard DLLs removed. pythonXX.dll is no problem. tcl und tk, which make the...
1
by: Brian Donovan | last post by:
Hi All, I'm trying to get xpath to work with the libxml2 python bindings. I'm using the following doc = libxml2.parseFile(filename) result =...
1
by: Funduk | last post by:
Hello, So I've been playing with Python and Pygame for a while and I decided I wanted to make a real executable so I could send that stuff over...
17
by: Thomas Heller | last post by:
py2exe 0.6.1 released ===================== py2exe is a Python distutils extension which converts python scripts into executable windows...
2
by: Laszlo Nagy | last post by:
I wrote a little win32 console application that uses libxml2. It is working fine. If I create an .exe version, I get this error when I try to start...
1
by: cesar.ortiz | last post by:
Hi all, I have created an example using libxml2 based in the code that appears in http://xmlsoft.org/python.html. My example processes an enough...
1
by: Jimmy Retzlaff | last post by:
py2exe 0.6.8 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows...
0
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
0
by: Jimmy Retzlaff | last post by:
py2exe 0.6.9 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.