I am building a small app that will be loaded on to a user's machine and it will need to look in the same directory as the bundle for specific mp3 files. These mp3 files will not be bundled with the py file, so I don't need the sys._MEIPASS path, but just the system path to the bundle itself.
Or, if I'm thinking about this in the wrong way, please advise. I'm not familiar with building apps in this way. We need a small app to modify specific mp3 id3 tags for users. The mp3s will be on their local machine or a usb drive. My idea is to just drop the script where the mp3s are and run it.
By the way, this is what I have tried...
if getattr(sys, 'frozen', False):
basedir = sys._MEIPASS
else:
basedir = os.path.dirname(os.path.abspath(__file__))
mp3path = basedir + "/test.mp3"
When I test before building, it gives me the correct path:
/Users/name/path/to/file/test.mp3
When I run the bundle, the mp3 path is:
/var/folders/d8/67z60y2x7c73kk_m0w50w2pr0000gp/T/_MEI9qySOb/test.mp3
When I just use the dirname from __file__
, the path is my user folder
/Users/name/test.mp3