Esa T. H. Esa T. H. - 17 days ago 8
Python Question

Pygame.image.load() not working with PyInstaller

img_l = pygame.image.load("img.png")
screen.blit(img_l)


With Python Interpreter it works fine, image loads and
main.py
runs without problems, but when I make it into one file
.exe
with Pyinstaller,
.exe
crashes.

I've tried few
.spec
modifications, but few I've managed to find don't seem to help.

Any ideas sincerely appreciated.

EDIT: got it working with:

img_l = pygame.image.load(os.path.join('img.png'))
screen.blit(img_l, (0, 0))


Now it works as it should after going through PyInstaller :)

Answer

got it working with:

img_l = pygame.image.load(os.path.join('img.png'))
screen.blit(img_l, (0, 0))

Now it works as it should after going through PyInstaller :)