2017-08-04 1 views
2

私はtutorialで作ったゲームをcx_Freezeの実行可能ファイルに変換できません。私はvirtualenvを使用しており、cx_Freezeはバージョン5.0です。ゲームを実行すると、メッセージが表示されます。pygameをvirtualenvとcx_Freezeで実行可能ファイルに変換できません

Fatal Python error: Py_Initialize: unable to load the file system codec 
ImportError: No module named 'encodings' 

Current thread 0x00002c24 (most recent call first): 

以下は、ファイルを作成するときのトレースバックです。

(pygame) G:\Programming\scripts\Python\PyGame\compile_files>python setup.py build 
running build 
running build_exe 
creating directory build\exe.win32-3.5 
copying G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.win32-3.5\Slither.exe 
copying G:\Programming\scripts\Python\virtualenv\pygame\Scripts\python35.dll -> build\exe.win32-3.5\python35.dll 
Traceback (most recent call last): 
    File "setup.py", line 12, in <module> 
    executables=executables 
    File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\dist.py", line 349, in setup 
    distutils.core.setup(**attrs) 
    File "G:\python\Python35-32\Lib\distutils\core.py", line 148, in setup 
    dist.run_commands() 
    File "G:\python\Python35-32\Lib\distutils\dist.py", line 955, in run_commands 
    self.run_command(cmd) 
    File "G:\python\Python35-32\Lib\distutils\dist.py", line 974, in run_command 
    cmd_obj.run() 
    File "G:\python\Python35-32\Lib\distutils\command\build.py", line 135, in run 
    self.run_command(cmd_name) 
    File "G:\python\Python35-32\Lib\distutils\cmd.py", line 313, in run_command 
    self.distribution.run_command(command) 
    File "G:\python\Python35-32\Lib\distutils\dist.py", line 974, in run_command 
    cmd_obj.run() 
    File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\dist.py", line 219, in run 
    freezer.Freeze() 
    File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 623, in Freeze 
    self._FreezeExecutable(executable) 
    File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 225, in _FreezeExecutable 
    self._AddVersionResource(exe) 
    File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 165, in _AddVersionResource 
    trademarks = exe.trademarks) 
    File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 759, in __init__ 
    parts = version.split(".") 
AttributeError: 'NoneType' object has no attribute 'split' 

(pygame) G:\Programming\scripts\Python\PyGame\compile_files>` 

マイセットアップファイルは次のとおりです。

import cx_Freeze 
import os 
os.environ['TCL_LIBRARY'] = "G:\\python\\Python35-32\\tcl\\tcl8.6" 
os.environ['TK_LIBRARY'] = "G:\\python\\Python35-32\\tcl\\tk8.6" 

executables=[cx_Freeze.Executable("Game.py")] 

cx_Freeze.setup(
    name="Game", 
    options={"build_exe":{"packages":["pygame"],"include_files":["image1.png","image2.png"]}}, 
    description="Game", 
    executables=executables 
) 

イメージはsetup.pyファイルと同じディレクトリにあります。

答えて

0

は、あなたのセットアップファイルでこれを使用します。その後

from cx_Freeze import setup,Executable 
setup(name="NAME OF YOUR PROGRAM", 
     version="1.0", 
     description="as above", 
     executables=[Executable("NAME OF THE SCRIPT.py")]) 

を、あなたのプログラムと同じフォルダにフォルダにPNGファイルをドラッグします。

python setup.py build 

最後に、png、jpgなどのファイルをそのフォルダに入れます。

+0

あなたのリストに似ている私の現在のsetup.pyファイルを追加しました。 – Skiltvakt

+0

他のアイデア? – Skiltvakt

関連する問題