簡體   English   中英

將 .py 轉換為 .exe 時出現 cx_Freeze 錯誤

[英]cx_Freeze error when converting .py to .exe

所以我一直在到處尋找將.py 轉換為.exe 的方法,例如py2exe 和cx_Freeze。 我已經讓 cx_Freeze 接近工作了,但是我遇到了一個錯誤,我不知道如何修復它,也沒有看到它在網上的任何地方發布。 有誰知道這個錯誤是什么,更重要的是,我可以解決它的最簡單方法? 我正在嘗試轉換一個名為 catanimation.py 的簡單程序作為測試,其中包含一個名為 cat.png 的圖片。 一切都在我桌面上一個名為“嘗試”的文件夾中。 這是文件夾、文件和命令提示錯誤的屏幕截圖:單擊此處

我也有這里寫的代碼:

    #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 游戲制作成可執行文件! 如果您回復提前致謝!!

好吧,我想通了。 它在 32 和 64 之間混淆,因為我還安裝了舊版本的 Python,刪除它們后只剩下 3.4,然后將 3.4 文件復制到帶有 setup.py 的文件中,這是 Python setup.py 構建的命令提示符工作!

暫無
暫無

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

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