I'm trying to create an executable app on (MacOS). The app doesn't work.
from tkinter import *
import pickle
root=Tk()
root.geometry("200x200")
test={"test"}
with open('test.pkl', 'wb') as f:
pickle.dump(test, f)
filename='test.pkl'
try:
model = pickle.load(open(filename, 'rb'))
Label(text='loaded',fg="red").pack()
except:
Label(text='An error occurred.',fg="red").pack()
root.mainloop()
Terminal:
pyinstaller --onefile --windowed Yourfile.py
I found the alternative solution but not with the Pyinstaller. I used Pyinstaller instead of py2applet
Step 1: -Go to terminal
pip3 install py2app
Step 2:
py2applet --make-setup yourfile.py
Wrote setup.py
and
rm -rf build dist
Step 3: -Configured your setup file.
APP = ['yourfile.py']
DATA_FILES = ["test.pkl"]
OPTIONS = {'argv_emulation': False,}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Step 4: -Go terminal and then;
python setup.py py2app -A
Your App will be created in the "dist" file.
If you need more information look at the https://py2app.readthedocs.io/en/latest/tutorial.html