Compiling python code into one exe

I am trying to compile python code into one exe and I was not able to do this correctly.

  • I tried pyinstaller and this is the .spec file:

    # -*- mode: python -*-
    a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'programs\\toolbox.py'],
             pathex=['C:\\Users\\Ronaldo\\Desktop\\Python\\pyinstaller'])
    pyz = PYZ(a.pure)
    exe = EXE( pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name=os.path.join('dist', 'program.exe'),
          debug=False,
          strip=False,
          upx=True,
          console=False )
    

    Pyinstaller compiled perfectly, created one exe file that worked, but apparently other users who did not have the same version. Installed python (2.7.2) could not start it. It does not give any error, it just does not start. I tried this by sending it to several friends, and also tried in a virtual machine.

  • py2exe. ( ), . , exe "toolbox.exe ". , , :

    Problem signature:
      Problem Event Name:   APPCRASH
      Application Name: toolbox.exe
      Application Version:  0.0.0.0
      Application Timestamp:    49180193
      Fault Module Name:    StackHash_0a9e
      Fault Module Version: 0.0.0.0
      Fault Module Timestamp:   00000000
      Exception Code:   c0000005
      Exception Offset: 01b61fcb
      OS Version:   6.1.7601.2.1.0.256.1
      Locale ID:    1033
      Additional Information 1: 0a9e
      Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
      Additional Information 3: 0a9e
      Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
    

    setup.py:

    from distutils.core import setup
    import py2exe, sys, os
    
    sys.argv.append('py2exe')
    
    setup(
        options = {'py2exe': {'bundle_files': 1}},
        windows = [{'script': "toolbox.py"}],
        zipfile = None,
    ) single.py file:
    

    single.py:

    import os, sys, ctypes
    
    ctypes.windll.user32.MessageBoxA(0,
        "curdir: %s\nexedir: %s\nsys.winver: %s" % (
            os.path.abspath(os.curdir),
            os.path.abspath(os.path.dirname(sys.argv[0])),
            sys.winver,
        ), "%s - Message" % os.path.basename(sys.executable), 0x30
    )
    

, , tkinter, sys, random win32clipboard (pywin). ? , ?

: Joël tip . , python 2.7. :

C:\Users\XXXXX\Desktop>program.exe
Found embedded PKG: C:\Users\XXXXX\Desktop\program.exe
Extracting binaries
Setting up to run child
Setting magic environment var
Creating child process
Waiting for child process to finish...
Found embedded PKG: C:\Users\XXXXX\Desktop\program.exe
workpath: C:/Users/XXXXX/AppData/Local/Temp/_MEI14042/
manifestpath: C:/Users/XXXXX/AppData/Local/Temp/_MEI14042/program.exe.manifest
Activation context created
Activation context activated
C:\Users\XXXXX\AppData\Local\Temp\_MEI14042\python27.dll
Manipulating evironment
PYTHONPATH=C:/Users/XXXXX/AppData/Local/Temp/_MEI14042;C:/Users/XXXXX/Desktop
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz

, .

+4
1

: , debug PyInstaller?

specfile:

exe = EXE( pyz,
           [...]
           debug=True,
           [...])

(: : console=True)

, . , ( ).


, , PyInstaller , .

Tcl , Tkinter: : Python, Pyinstaller

:

Makespec.py, : python Makespec.py [opts] [...] :

[...]

-K, --tk TCL/TK .

spec . , , EXE.

+2

All Articles