cx_Freeze构建的exe。无法打开包含的文件

时间:2019-12-04 16:51:45

标签: python python-3.x cx-freeze

我有python文件'main.py',并且使用了'car.png',我成功构建了可执行文件,但是当我打开可执行文件时,出现以下错误:

Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "C:\Users\IT Lab\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 40, in run
    module.run()
  File "C:\Users\IT Lab\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 23, in run
    exec(code, {'__name__': '__main__'})
  File "main.py", line 32, in <module>
pygame.error: Couldn't open car.png

构建exe的文件的代码。是:

import cx_Freeze

executables = [cx_Freeze.Executable('main.py')]

cx_Freeze.setup(
    name='RaceCar',
    options={'build_exe': {'packages': ['pygame'],
                           'include_files': ['car.png']}},
    executables=executables
)

此文件的名称是'convert_to_exe.py' 我从与“ main.py”相同的目录中的cmd调用它,但是就像我说的那样,构建没有错误

0 个答案:

没有答案