I'm trying to compile a stand alone exe with PyInstaller following the instructions here on SO, but I'm unable to include my two .png
image files in the process.
I have added this code to my one and only script, main.py
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
And I have defined my images background.png
and closed.png
properly
background = resource_path("background.png")
close = resource_path("closed.png")
I create the .spec file and have added this line to it
a.datas += [('icon.ico', 'C:\Users\Michael\Desktop\lolping\icon.ico','DATA'), ('background.gif','C:\Users\Michael\Desktop\background.png','DATA'), ('closed.png','C:\Users\Michael\Desktop\closed.png','DATA')],
But after building my .exe and running it I get this error:
File "main.spec", line 12
a.datas += [('background.png', 'C:\\Deskop\\background.png','DATA',
('closed.png', 'C:\\Desktop\\closed.png','DATA')],
^
SyntaxError: invalid syntax