Mittwoch, 17. März 2010

py2exe VC-library woes (part two)

I've got a shiny new desktop pc in my office last week. First thing to setup was my development environment. So among other stuff I installed python (2.6.4), wxpython, py2exe and tested the install with one of my projects.

But generating a stand alone windows executable failed immediately:
python py2exe
...bailed out with following message:
*** searching for required modules ***
*** parsing results ***
*** finding dlls needed ***
error: MSVCP90.dll: No such file or directory

What happended?

This time I installed python with local admin rights "for all users". As noted in my first post about distributing python apps for windows python >2.6 (on the windows platform) is linked against Microsoft Visual C libraries (VC90) and the preferred way for installing those dependencies is to put them into the Windows\WinSxS system directory - where assemblies can be shared "side by side" among applications.

That's exactly what the python msi installer does when it is given the "install for all users" option with the required admin-privileges. But unfortunately current versions of py2exe don't seem to check system directories when they scan for required modules and thus fail. This seems to be confirmed as a bug.

The workarounds:

You have two obsolete and one recommended options:
  1. Locate the correct version and copy msvcp90.dll and msvcr90.dll into pythons DLLs directory
  2. Install Python without admin rights (for yourself only)
  3. [EDIT 2010-09-19] RECOMMENDED: add msvcp90.dll to dll_excludes of your py2exe options in like so:

## note the exclusion of msvcp90.dll to fix the error in py2exe
my_dll_excludes = [
    'libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll',
    'tcl84.dll', 'tk84.dll', 'msvcp90.dll'
    options = {...
               "py2exe": {"dll_excludes": my_dll_excludes, ...
Take care to package the correct version of msvcp90.dll and msvcr90.dll with your app according to this blog.

Keine Kommentare:

Kommentar veröffentlichen