Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py2exe + pywin32 MemoryLoadLibrary import fail when bundle_files=1

I have created a simple program which uses pywin32. I want to deploy it as an executable, so I py2exe'd it. I also didn't want a huge amount of files, so I set bundle_files to 1 (meaning bundle everything together). However, when I attempt running it, I get:

Traceback (most recent call last):
  File "pshelper.py", line 4, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "win32.pyc", line 8, in <module>
  File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd

In my setup script, I tried doing packages=["win32ui"] and includes=["win32ui"] as options, but that didn't help. How can I get py2exe to include win32ui.pyd?

I don't have this problem if I don't ask it to bundle the files, so I can do that, for now, but I'd like to know how to get it to work properly.

like image 690
Claudiu Avatar asked Jul 30 '10 14:07

Claudiu


2 Answers

Are you sure that the problem is that win32ui.pyd is not included? The stack trace isn't exactly the same as noted in the wiki, but check this out: http://www.py2exe.org/index.cgi/Py2exeAndWin32ui.

like image 79
Jeremy Brown Avatar answered Nov 08 '22 02:11

Jeremy Brown


The work-around that has worked best so far is to simply re-implement the pywin32 functions using ctypes. That doesn't require another .pyd or .dll file so the issue is obviated.

like image 24
Claudiu Avatar answered Nov 08 '22 01:11

Claudiu