Search code examples
py2app

How to refer to files that were added via the data_files attribute?


With py2app, say I added several files to my package using this:

DATA_FILES = [
    ('images', ['images/picture.jpg', 'images/picture2.png']),
    ('images/icons', ['images/icons/ico1.ico'])
]

and in my original I used to access these files using './images/picture.jpg' for example. How should I refer to them now?

I've tried both using the same path and using ./Contents/Resources//images/picture.jpg but neither work


Solution

  • In general, paths obtained via os.getcwd() refer to ./Contents/Resources/ after running py2app on my machine.

    To better understand your exact problem, run the executable file in *.app/Contents/MacOS/, then copy and share the traceback error message that comes up in your Terminal console. Also, try to insert print statements to analyse your paths in Terminal.