1

I'm trying to generate a setup for my Pygame program using Pyinstaller. The program has 1 main.py file that imports 4 other .py files (config.py, snake.py, fruit.py, game.py). So, after installing Pyinstaller i just run:

pyinstaller --onefile main.py

And it generated all files normally. But when i try to run the main.exe file inside the dist folder, this is what happens:

pygame 2.0.1 (SDL 2.0.14, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "main.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\lucena\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "game.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\lucena\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "config.py", line 74, in <module>
  File "config.py", line 33, in img
FileNotFoundError: No such file or directory.
[2468] Failed to execute script main

I tried to modify the data array inside the .spec file but i don't know if i did it right because i'm still getting the error message.

Could someone help me find out what is causing the error? Thanks.

I'm using Windows 10, Python 3.8.5 and Pygame 2.0.1.

n4tm
  • 77
  • 4

0 Answers0