1
因此,我一直在尋找將.py轉換爲.exe的方法,例如py2exe和cx_Freeze。我已經接近cx_Freeze的工作,但我得到了一個錯誤,我不知道如何解決它,並沒有看到它張貼在任何地方在線。有誰知道這個錯誤是什麼,更重要的是,我能修復它的最簡單方法是什麼? 我想轉換一個簡單的程序,名爲catanimation.py作爲一個測試,其中有一個圖片涉及稱爲cat.png。一切都在我桌面上的一個名爲「嘗試」的文件夾中。以下是該文件夾,文件和命令提示符錯誤的屏幕截圖:Click here。將.py轉換爲.exe時發生cx_Freeze錯誤
我也有代碼寫在這裏:
#This is setup.py
import cx_Freeze
executables = [cx_Freeze.Executable("catanimation.py")]
cx_Freeze.setup(
name="Cat Animation",
options={"build_exe": {"packages":["pygame"],
"include_files":["cat.png"]}},
executables = executables
)
這裏是命令提示信息:
C:\Users\Nick\Desktop\attempt>setup.py build
running build
running build_exe
Traceback (most recent call last):
File "C:\Users\Nick\Desktop\attempt\setup.py", line 10, in <module>
executables = executables
File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
distutils.core.setup(**attrs)
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 231, in run
metadata = metadata)
File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 130, in __init__
for n in self._GetDefaultBinPathExcludes() + binPathExcludes]
File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 270, in _GetDe
faultBinPathExcludes
import cx_Freeze.util
ImportError: DLL load failed: %1 is not a valid Win32 application.
C:\Users\Nick\Desktop\attempt>
我目前使用Python 3.4.0與pygame的和cx_Freeze。請幫我弄清楚這個問題以及如何解決這個問題,這樣我就可以用cx_Freeze將python遊戲製作成可執行文件!如果您回覆,請提前致謝!