1. Fredrik Lundh
  2. pil-117
  3. Issues
Issue #1 open

Windows build of _imagingft module fails to load

Alexander Petrov
created an issue

==== Problem ====

Right after installing (from PyPi or directly running PIL-1.1.7.win32-py2.6.exe): {{{ D:\alex\image-index.scripts>python Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import _imagingft Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. }}}

==== Cause ====

The manifest descriptor embedded with _imagingft.pyd contains dependency on DEBUG version of C++ runtime: {{{ ... <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> ... }}}

==== Solution ====

Remove mentioned lines/dependency from manifest

Comments (8)

  1. Fredrik Lundh repo owner

    Strange. I haven't ever build a debug build on the machine I use to cut the distribution files, and it does work for me on a "clean" Windows XP machine (i.e. one without any compilers or non-standard stuff). I'll dig a bit more, but it might be a distutils problem rather than a PIL-specific problem.

  2. rocketmonkeys

    I'm having the same problem. Windows XP SP3, Python 2.6.5, PIL 1.1.7 (intalled via easy_install), and packaged up using py2exe.

    On my system, the problem is in: C:\Python26\Lib\site-packages\PIL-1.1.7-py2.6-win32.egg\_imagingft.pyd

    I opened that file in a text editor, and I see this:

    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
          <requestedPrivileges>
            <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
          </requestedPrivileges>
        </security>
      </trustInfo>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
    </assembly>PPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDING
    

    The problem here is the Microsoft.VC90.DebugCRT dependency. I changed this to:

    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
          <requestedPrivileges>
            <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
          </requestedPrivileges>
        </security>
      </trustInfo>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
                  
                           
                                                                                                                                                                               
                            
                   
    </assembly>PPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDING
    

    And the problem is solved - no more dependency on the non-redistributable MFC dll's. I replaced all chars with spaces to maintain spacing/padding, since I figured that might be important (due to the "PADDINGXX" chars following). Not sure if it'll work if that section is simply deleted.

    So it seems like a bug in the PIL-1.1.7-py2.6-win32.exe installation file. Not sure if it exists in the source distro, or other python versions.

    Can someone confirm this bug for me? I fixed my own problem, but I really have no idea what I'm doing and I hope that just hacking that piece off is the correct fix. Thanks!

  3. rocketmonkeys

    Attached my modified _imagingft.pyd. The only change I've made is to modify the embedded manifest to remove links to the DebugCRT files.

    No guarantees on this one - seems to work fine for me, but I really just hacked around in a binary file with a text editor, so it's quite possible something is now screwed up.

    Original file came from PIL-1.1.7-py2.6-win32.egg.

  4. Anonymous

    Still an issue in PIL-1.1.7.win32-py2.6.exe. When freezing the application, pyinstaller also picks up a dependency on the debug VC library, and it is coming from _imagingft.pyd.

  5. Phil Mayes

    I can confirm the 2011-11-19 comment about freezing on Windows 8 using pyinstaller 1.5. Hacking _imagingft.pyd as rocketmonkeys describes fixes it for me. (I couldn't download his fix - I got access denied.)

  6. Esteban Roncancio

    still an issue on PIL-1.1.7.win32-py2.7.exe triied changing file to no avail and file download gives me a server problem. could anyone upload their fix again?

    EDIT: this fixed it from me "The _imageft.pyd DLL of PIL 1.1.7 has a erroneous dependency on the Debug CRT. You can safely remove the dependency by editing the file with a hex editor. Open the file on your hex editor, search for the string "assembly" and comment out the Debug CRT. The block should look like:

    <!--endency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependen--> "

  7. Log in to comment