473,568 Members | 3,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4011
"Rene Olsthoorn" <ro*@post.com > wrote in
news:3f******** *************@n ews.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.n et>

Jul 18 '05 #2
"Rene Olsthoorn" <ro*@post.com > wrote in message
news:3f******** *************@n ews.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 "win32serviceut il.pyo", line 663, in SvcRun
File "UMXWIN32SVC.py o", line 41, in SvcDoRun
File "Rose\WebServer \UMXMServer.pyo ", line 53, in ?
File "Rose\WebServer \umx_handler.py o", line 16, in ?
File "Rose\WebServer \HTTPHandler.py o", line 95, in ?
File "Rose\WebServer \XMLProcessor.p yo", line 34, in ?

exceptions.Impo rtError: 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******** *************@n ews.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 "win32serviceut il.pyo", line 663, in SvcRun
File "UMXWIN32SVC.py o", line 41, in SvcDoRun
File "Rose\WebServer \UMXMServer.pyo ", line 53, in ?
File "Rose\WebServer \umx_handler.py o", line 16, in ?
File "Rose\WebServer \HTTPHandler.py o", line 95, in ?
File "Rose\WebServer \XMLProcessor.p yo", line 34, in ?

exceptions.Impo rtError: 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******** *************@n ews.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 "win32serviceut il.pyo", line 663, in SvcRun
File "UMXWIN32SVC.py o", line 41, in SvcDoRun
File "Rose\WebServer \UMXMServer.pyo ", line 53, in ?
File "Rose\WebServer \umx_handler.py o", line 16, in ?
File "Rose\WebServer \HTTPHandler.py o", line 95, in ?
File "Rose\WebServer \XMLProcessor.p yo", line 34, in ?

exceptions.Impo rtError: 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******** *************@n ews.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 "win32serviceut il.pyo", line 663, in SvcRun
File "UMXWIN32SVC.py o", line 41, in SvcDoRun
File "Rose\WebServer \UMXMServer.pyo ", line 53, in ?
File "Rose\WebServer \umx_handler.py o", line 16, in ?
File "Rose\WebServer \HTTPHandler.py o", line 95, in ?
File "Rose\WebServer \XMLProcessor.p yo", line 34, in ?

exceptions.Impo rtError: 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
7049
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 _tkinter.pyd seems to expect them in the same directory (Question 1) Is there a configration or path setting in py2exe/distutils I
1
1875
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 nodes in it and I'm trying to get an element named 'element' (from an relaxng schema).
1
2581
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 skillz</sarcasm>. Everything was going great I went and got all the newest software (including Distutils and PY2EXE) and read the docs on making a setup...
17
3412
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 installation. Console and Windows (GUI) applications, windows NT services, exe and dll COM servers are supported. Changes in this release:
2
2525
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 last): File "MyProgram.py", line 3, in ? File "mylib\item.pyc", line 5, in ? ImportError: dynamic module does not define init function (initlibxml2) ...
1
4118
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 consumption rises till the process ends (I check it with the 'top' command). I don´t know if I am forgetting something in the code, as I have not...
1
2969
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 installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.8:
0
1506
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
3101
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 installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.9:
0
7692
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7913
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.