簡體   English   中英

Cx_freeze問題

[英]Problems with Cx_freeze

如果我實際上是在尋求您的幫助,那是因為我花了很多時間沒有時間解決問題:

我想將python腳本編譯成.exe :(我正在使用Python 32位3.1.4和pygame)

我有4個文件: Class .pyc,_Class_game.pyc,_ressources.pyc et main.py和包含所有圖像和歌曲的文件夾@ressources

這是我的scritp 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

)

這會使用python(已編譯)和我的游戲創建一個文件夾“ exe.xin32-3.1”

接下來,我使用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或某個地方啟動時下載它們))

MSI的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM