How do I debug a py2exe 'application failed to initialize properly' error?

前端 未结 4 1626
孤街浪徒
孤街浪徒 2021-01-05 07:15

I\'m very new to Python in general, but I made an app in Python 2.6 / wxPython 2.8 that works perfectly when I run it through Python. But I wanted to go a step further and b

相关标签:
4条回答
  • 2021-01-05 07:48

    You are not supposed to copy ALL of the .dlls it complains about! Some of them are Windows system files, and they are present in the correct places on the system. If you copy them into the dist folder, things won't work correctly.

    In general, you only want to copy .dlls which are specific to your application. Not system .dlls. In some situations you may need to ship vcredist_xx.exe in your installer to get the MSVC runtime on the system. You should never try to ship those .dlls files "raw" by yourself. Use the redist package, it will save you time and frustration.

    Have you tried following the directions here: http://wiki.wxpython.org/SmallApp ?

    0 讨论(0)
  • 2021-01-05 07:59

    Note that there is a later version of the Visual C++ 2008 Redistributable package: SP1. However, both the SP1 and the earlier release don't install the DLLs into the path. As the download page says (my emphasis):

    This package installs runtime components of C Runtime (CRT), Standard C++, ATL, MFC, OpenMP and MSDIA libraries. For libraries that support side-by-side deployment model (CRT, SCL, ATL, MFC, OpenMP) they are installed into the native assembly cache, also called WinSxS folder, on versions of Windows operating system that support side-by-side assemblies.

    You will probably find these files in the %WINDIR%\WinSxS folder and not in the path.What I think you need to do is incorporate the manifest information for the relevant DLLs (found in %WINDIR%\WinSxS\Manifests) into your setup.py. I added the following section:

    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.VC90.CRT"
                version="9.0.30729.4918"
                processorArchitecture="X86"
                publicKeyToken="1fc8b3b9a1e18e3b"
                language="*"
            />
        </dependentAssembly>
    </dependency>
    

    immediately after the existing <dependency> section, and rebuilt the exe: it ran without problems. Note: depending on exactly what version of the Visual C++ files you installed, the above info may not be exactly correct. Look at the manifests on your system and use the correct version, publicKeyToken etc.

    Alternatively, look at this answer for how to deploy the DLLs with your application (as opposed to assuming they already exist on the target system). Oh ... I see you asked that original question ;-)

    0 讨论(0)
  • 2021-01-05 07:59

    I've used py2exe before and I've never run across a situation like this....

    However, it sounds like missing dependencies are your problem.....

    Does the packaged program work on your machine but not on others?

    If so, run the packaged application within DEPENDS (dependency walker) on both machines and compare to hopefully discern which packages didn't get included.

    Good Luck

    0 讨论(0)
  • 2021-01-05 08:12

    Are you sure that you give the same dlls that the one used by wxPython.

    The vc++ dlls used by wxpython can be downloaded from the wxpython download page. Did you try these one?

    0 讨论(0)
提交回复
热议问题