Cx_freeze 的问题

Problems with Cx_freeze

如果我真的向你寻求帮助,那是因为我花了很多时间来解决我的问题:

我想将我的 python 脚本编译成 .exe: (我正在使用 Python 32 位 3.1.4 和 pygame)

我有 4 个文件:Class.pyc、_Class_game.pyc、_ressources.pyc 和 main.py 和一个包含所有图片和歌曲的文件夹@ressources

这是我的脚本setup.py:

import cx_Freeze
executables = [cx_Freeze.Executable("main.py"), base = "Win32GUI"]
cx_Freeze.setup(
    name="Strike The square",
    version = "2.0",
    description = "Jeu Strike The Square, V2.1",
    options={"build_exe": {"packages":["pygame"],
                           "include_files":   ["_Class_.pyc","_Class_game.pyc","_ressources.pyc"]}},
    executables = executables

)

这将创建一个文件夹 "exe.xin32-3.1",其中包含 python(已编译)和我的游戏

接下来,我使用 inno setup 构建安装程序并添加文件夹@ressources

在我的电脑上,它工作得很好,但是当我的一个朋友想玩时(他没有 python 和 pygame),游戏会产生这个错误: [错误][1]

然后...我认为此错误来自 windows' 资源,但我不知道如何解决... 选项(在 setup.py 中):

include_msvcr = True

没用...

感谢您的回答,请原谅我的英语...

Hawk_Eyes

PS:这是我的游戏导入的

try:
    import pygame,time, ctypes
    from random import randint
    from pygame.locals import *
    from math import sqrt 
    from _ressources import Shared
except ImportError as e:
    print("Erreur du chargement du module: {0}".format(e))

不确定这是否有帮助,但这是我的安装文件的副本,我用它来编译 Pygame、Pubnub 和各种东西。注意我不包括我想包括的文件。安装程序会自动找到所需的文件。

import sys
from cx_Freeze import setup, Executable

exe = Executable(
    script = r"launcher.py",
    base = 'Win32GUI',
    icon = None,
    targetName = "launcher.exe"
    )

setup(
    version = "0.1",
    description = "launcher",
    author = "Joshua Nixon",
    name = "launcher",
    executables = [exe]
    )

$ cd path/to/files
$ python file.py build

编辑

我最近发现您可以使用 cx_freeze 创建 .MSI 文件,这非常适合分发。如果程序使用图像,那么(因为你不能将图像与 MSI(据我所知)捆绑在一起,你创建了一个小功能,可以在启动时从 imgur 或某个地方下载它们))

setup.py 微星

import sys
from cx_Freeze import setup, Executable

company_name = "JoshuaNixon"
product_name = "Test"

bdist_msi_options = {
    'add_to_path': False,
    'initial_target_dir': r'[ProgramFilesFolder]\%s' % (company_name),
    }

if sys.platform == 'win32':
    base = 'Win32GUI'
else:
    base = None

exe = Executable(script='launcher.py',
                 base=base,
                 icon="mushroom.ico",
                )

setup(name=product_name,
      version='1.0.0',
      description='blah',
      executables=[exe],
      options={'bdist_msi': bdist_msi_options})

$ cd path/to/files
$ python file.py bdist_msi