473,385 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3999
"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 mass of mega bytes, cannot be removed because...
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 = doc.xpathEval('//*') My test XML file has 10...
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 to my friends to show off my <sarcasm>maad...
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 programs, able to run without requiring a python...
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 the program: Traceback (most recent call...
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 amount of html files to see that the memory...
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 programs, able to run without requiring a Python...
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 programs, able to run without requiring a Python...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.