I have a program that works correctly from the .py file and .exe file created with pyinstaller (makes a game displaying images from 5 folders in a assets folder that is in the same location as the .py file. This is the code to get my images.
for path in glob.glob('assets/*/'): # In all folders in 'assets':
for picture in glob.glob(f'{path}*.png'): # For all images in path:
screen = pygame.transform.scale(pygame.image.load(picture), (100,100))
pictures.append(screen)
My problem came to making a mac version of my program. I created a mac VM, downloaded python and pyinstaller, transferred the files (aforementioned main.py and assets folder) and ran the following in console in the directory containing main.py:
pyinstaller main.py
I also tried adding the --onefile and --windowed tags (separately and together) and moved the main.app file in the same directory as main.py and it failed to run and I got the following error when opening it from console
LSOpenURLsWithRole() failed with error -10810 for the file /Users/username/Desktop/main/main.app.
I also tried using py2app and ran the following in the console in the directory with main.py
% py2applet --make-setup main.py
% nano setup.py
% python3 setup.py py2app -A
This created main.app and let me run it and it opened my application but didn't use any of my images in it as if they weren't available.
I also tried editing the DATA_FILES = []
in setup.py to all of the following, each without success:
'assets'
'assets/'
'assets/*'
'assets/**'
'assets/*/'
'assets/*/*'
'assets/*/*.png'
'*'
Please let me know if you need any other information or have any solutions for using pyinstaller or py2app to make a .app file for my program and uses images in directories in my "assets" directory.
Thanks in advance