I am trying to create a python 3.7.7 based application on Mac OS Catalina 10.15 using pyinstaller 3.6. I installed python using Homebrew and pyinstaller with pip.
This python code, named GUI.py, needs five images that are stored in a folder named "resources" and everything is within the "Project" folder. So the structure of the project is like follows:
Project:
- GUI.py
- resources:
- image1.png
- image2.png
- image3.png
- image4.png
- image5.png
The path that GUI.py uses to locate the images is like "resources/image1.png", "resources/image2.png" and so on for the rest of the images.
I open a terminal and type the following:
pyinstaller --add-data /Users/user/Desktop/Project/resources/*:resources /Users/user/Desktop/Project/GUI.py
Then the dist and build folders are created as well as the GUI.spec file.
The problem appears now when i go to the dist/GUI folder and i find the executable. I double click it to open my application but the following error appears:
FileNotFoundError: [Errno2] No such file or directory: 'resources/image1.png'
However, if i open the terminal and go to the dist/GUI directory where the GUI executable is located and execute it manually:
./GUI
it works perfectly and the application is opened.
It happens the same when i add the option --nocnosole
to the pyinstaller instruction:
pyinstaller --add-data /Users/user/Desktop/Project/resources/*:resources --noconsole /Users/user/Desktop/Project/GUI.py
This creates a Mac OS application named GUI that does not open when i dobule click it. But, just as before, if i open a terminal and go to GUI/Contents/MacOS/ i find the GUI exectuable and execute it manually:
./GUI
then it works fine.
I don't know if i am adding correctly the resources folder containing the images or if it is a Mac OS problem with pyinstaller.
I add some notes with extra information:
- I made the same whole process in Windows 10 and Ubuntu 18.04.1 and it works perfectly. I can create the executable contained in the dist folder and export it to other computers and it just works.
- I used a different way to add data in the pyinstaller command and still it does not work:
pyinstaller --add-data /Users/user/Desktop/Project/:. /Users/user/Desktop/Project/GUI.py
- I followed the solutions provided in Pyinstaller adding data files but nothing works
- The python application is a graphic user interface that uses tkinter, pyserial and PIL. Also, i used custom packages that i add with the -p option in the pyinstaller command but ommited here as it is not a source of errors.
I looked everywhere for a solution, read the documentation that pyinstaller provides referring to adding data but i found nothing.