making a python program executable

前端 未结 3 2058
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 16:02
from distutils.core import setup
import py2exe, sys, os

sys.argv.append(\'py2exe\')

setup(
    options = {\'py2exe\': {\'bundle_files\': 1}},
    windows = [{\'script\         


        
3条回答
  •  佛祖请我去吃肉
    2021-02-06 16:35

    I don't know your py2exe tool, but we usually use this way to convert py to exe:

    1. Download and install Standard Python Software: http://www.python.org/download/

    2. Download PyInstaller via link below: http://pyinstaller.python-hosting.com/

    3. Unpack the archive, that you have downloaded! In this examople, the directory of the unpacked files:

    4. In the directory, run Configure.py. It must be run before trying to build anything.

    5. Create a spec file for your project:

      python Makespec.py -F -p  
        -F: Produce a single file deployment.
        -p : Set base path for import (like using PYTHONPATH).
           ( e.g.: C:\Program Files\Python24\Lib\ )
        : Path to python script.
      

    6 Build your project!

        python Build.py 
          : Path to the specfile, that have been created in step 4! 
    
        The full path to :
          //.spec
    
    1. The binary file will be placed in the directory of .

提交回复
热议问题