How do I compile a python program with the resources needed into a package?

Viewed 21

I have a python program written with its GUI done with tkinter. The entire program is split up into 5 .py files. I also have 5 images that I would like to use as icons. The user data is stored in a subdirectory named Profile into .txt files. I am using the pickle library to write the datastructure into the .txt files. All the necessary icons, .py files and subdirectories are in a directory for the project. The functions to access and store them are as follows:

access

store

resourcePath

I am using pyinstaller as most tutorials I have found online suggest using this tool to help me get an executable. Running the command pyinstaller -w -F MPM.py (MPM is the main file that starts the program) there are no errors, but the resulting .exe is not behaving correctly at all. Firstly, it cannot find the path to the icons and it gave the error:

error

I tried addressing this by looking at a post discussing the issue which led me to write the resourcePath function above, but it still did not solve the issue. I commented out the part of the code that dealt with the icons to see if the rest would work but, it isn't writing to the subdirectory. I added an error window to print the path. The original path is:

original path

and the new path is:

different path

Is there a way to compile the program into a directory with a subdirectory for the profiles and also a subdirectory like a resource folder to hold the icons? I can't seem to find a good tutorial online for this. This is my first time compiling a program to an executable and I am very confused.

Here's a screen shot of the project directory: directory

0 Answers
Related