Created an app with Pyinstaller on Mac, the app doesn’t work but the shell file does. Why?

I am creating an app that generates a schedule for my school. Here is the python code for it:

import tkinter as tk
from tkinter import ttk
import os
import json
import logging
import datetime
import sys

logging.basicConfig(level=logging.DEBUG, filename='app.log', filemode='w',
                    format='%(name)s - %(levelname)s - %(message)s')

if getattr(sys, 'frozen', False):
    application_path = os.path.dirname(sys.executable)
else:
    application_path = os.path.dirname(__file__)
  
PREFERENCES_FILE = os.path.join(application_path, "user_preferences.json")

def save_preferences(data):
    try:
        with open(PREFERENCES_FILE, 'w') as f:
            json.dump(data, f)
        logging.info("Preferences saved successfully.")
    except Exception as e:
        logging.error(f"Failed to save preferences: {e}")
      
def load_preferences():
    try:
        if os.path.exists(PREFERENCES_FILE):
            with open(PREFERENCES_FILE, 'r') as f:
                return json.load(f)
    except Exception as e:
        logging.error(f"Error reading preferences: {e}")
    return None

def delete_preferences():
    try:
        if os.path.exists(PREFERENCES_FILE):
            os.remove(PREFERENCES_FILE)
            logging.info("Preferences deleted successfully.")
    except Exception as e:
        logging.error(f"Failed to delete preferences: {e}")
      
def show_schedule(day, preferences):
    schedule = preferences['schedule']
    day_schedule = schedule.get(day, [])
    schedule_text = f"Schedule for {day}:n"
    for time_range, subject_key in day_schedule:
        subject = preferences['subjects'].get(subject_key, "Free")
        schedule_text += f"{time_range} - {subject}n"
    schedule_label.config(text=schedule_text)
  
def setup_preferences():
    def save_and_close():
        subjects = {
            'MESH1': mesh1_var.get(),
            'MESH2': mesh2_var.get(),
            'MESH3': mesh3_var.get(),
            'MESH4': mesh4_var.get(),
            'WL': wl_var.get(),
            'WELLNESS': 'Wellness',
            'ELECTIVE1': elective1_entry.get(),
            'ELECTIVE2': elective2_entry.get(),
            'CLUB': club_entry.get(),
            'GEOMETRY': 'Geometry' if geometry_var.get() else None,
            'RECESS': 'Recess',
            'LUNCH': 'Lunch',
            'ACADEMIC_COACHING': 'Academic Coaching',
            'ADVISORY': 'Advisory'
        }
        preferences = {
            'subjects': subjects,
            'schedule': load_default_schedule(geometry_var.get())
        }
        save_preferences(preferences)
        setup_root.destroy()
        main_app()
      
    setup_root = tk.Tk()
    setup_root.title("Setup Preferences")
  
    mesh_options = ["Math", "English", "Science", "History"]
    wl_options = ["Spanish", "French", "FOL"]
    mesh1_var, mesh2_var, mesh3_var, mesh4_var, wl_var = tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar()
    geometry_var = tk.BooleanVar()
  
    ttk.Label(setup_root, text="Select MESH1:").pack()
    ttk.Combobox(setup_root, textvariable=mesh1_var, values=mesh_options).pack()
    ttk.Label(setup_root, text="Select MESH2:").pack()
    ttk.Combobox(setup_root, textvariable=mesh2_var, values=mesh_options).pack()
    ttk.Label(setup_root, text="Select MESH3:").pack()
    ttk.Combobox(setup_root, textvariable=mesh3_var, values=mesh_options).pack()
    ttk.Label(setup_root, text="Select MESH4:").pack()
    ttk.Combobox(setup_root, textvariable=mesh4_var, values=mesh_options).pack()
    ttk.Label(setup_root, text="Select WL:").pack()
    ttk.Combobox(setup_root, textvariable=wl_var, values=wl_options).pack()
  
    ttk.Checkbutton(setup_root, text="Include Geometry", variable=geometry_var).pack()
  
    ttk.Label(setup_root, text="Enter AM ICE:").pack()
    elective1_entry = ttk.Entry(setup_root)
    elective1_entry.pack()
    ttk.Label(setup_root, text="Enter PM ICE:").pack()
    elective2_entry = ttk.Entry(setup_root)
    elective2_entry.pack()
    ttk.Label(setup_root, text="Enter Club:").pack()
    club_entry = ttk.Entry(setup_root)
    club_entry.pack()
  
    ttk.Button(setup_root, text="Save and Start", command=save_and_close).pack(pady=10)
    setup_root.mainloop()
  
def load_default_schedule(include_geometry):
    today = datetime.datetime.today().weekday()  # Monday is 0 and Sunday is 6
    geometry_days = [0, 2, 4]  # Monday, Wednesday, Friday
  
    schedule = {
        'A': [("8:10-8:30", "ADVISORY"), ("8:30-9:20", "CLUB"), ("9:20-10:10", "MESH1"),
              ("10:10-10:30", "RECESS"), ("10:30-11:20", "MESH3"), ("11:20-12:10", "MESH2"),
              ("12:10-12:40", "LUNCH"), ("12:40-1:30", "WL"), ("1:30-2:20", "MESH4"), ("2:20-3:10", "ELECTIVE2")],
        'B': [("8:10-8:30", "ADVISORY"), ("8:30-9:20", "ELECTIVE1"), ("9:20-10:10", "WL"),
              ("10:10-10:30", "RECESS"), ("10:30-11:20", "MESH2"), ("11:20-12:10", "MESH3"),
              ("12:10-12:40", "LUNCH"), ("12:40-1:30", "MESH4"), ("1:30-2:20", "MESH1"), ("2:20-3:10", "ELECTIVE2")],
        'C': [("8:10-8:30", "ADVISORY"), ("8:30-9:20", "ACADEMIC_COACHING"), ("9:20-10:10", "MESH2"),
              ("10:10-10:30", "RECESS"), ("10:30-11:20", "MESH4"), ("11:20-12:10", "MESH1"),
              ("12:10-12:40", "LUNCH"), ("12:40-1:30", "WL"), ("1:30-2:20", "MESH3"), ("2:20-3:10", "ELECTIVE2")],
        'D': [("8:10-8:30", "ADVISORY"), ("8:30-9:20", "ELECTIVE1"), ("9:20-10:10", "WL"),
              ("10:10-10:30", "RECESS"), ("10:30-11:20", "MESH4"), ("11:20-12:10", "MESH1"),
              ("12:10-12:40", "LUNCH"), ("12:40-1:30", "MESH3"), ("1:30-2:20", "MESH2"), ("2:20-3:10", "ACADEMIC_COACHING")],
        'E': [("8:10-8:30", "ADVISORY"), ("8:30-9:20", "ELECTIVE1"), ("9:20-10:10", "MESH1"),
              ("10:10-10:30", "RECESS"), ("10:30-11:20", "MESH3"), ("11:20-12:10", "MESH2"),
              ("12:10-12:40", "LUNCH"), ("12:40-1:30", "WELLNESS"), ("1:30-2:20", "MESH4"), ("2:20-3:10", "ELECTIVE2")],
        'F': [("8:10-8:30", "ADVISORY"), ("8:30-9:20", "ELECTIVE1"), ("9:20-10:10", "WL"),
              ("10:10-10:30", "RECESS"), ("10:30-11:20", "MESH2"), ("11:20-12:10", "MESH3"),
              ("12:10-12:40", "LUNCH"), ("12:40-1:30", "MESH4"), ("1:30-2:20", "MESH1"), ("2:20-3:10", "ACADEMIC_COACHING")]
    }
  
    if include_geometry and today in geometry_days:
        geometry_class = ("7:00-8:00", "GEOMETRY")
        for key in schedule:
            schedule[key].insert(0, geometry_class)
          
    return schedule

def main_app():
    preferences = load_preferences()
    if not preferences:
        setup_preferences()
        return
  
    root = tk.Tk()
    root.title("School Schedule")
  
    day_var = tk.StringVar(value='A')
    day_dropdown = ttk.Combobox(root, textvariable=day_var, values=list('ABCDEF'))
    day_dropdown.pack(pady=10)
  
    show_button = ttk.Button(root, text="Show Schedule", command=lambda: show_schedule(day_var.get(), preferences))
    show_button.pack(pady=5)
  
    reset_button = ttk.Button(root, text="Reset Preferences", command=lambda: [delete_preferences(), root.destroy(), setup_preferences()])
    reset_button.pack(pady=5)
  
    global schedule_label
    schedule_label = tk.Label(root, text="", justify=tk.LEFT)
    schedule_label.pack(pady=10)
  
    root.mainloop()
  
if __name__ == "__main__":
    main_app()
  

I tried to create the program on my Mac using this command:

pyinstaller --windowed --onefile --icon=/Users/jacob/ icon.iconset/857457.icns --name="School Schedule App" /Users/jacob/School_Schedule_App.py

When I tried to open the app by double clicking it, nothing happened. However, if I went into the package contents and then the MacOS folder, running the shell script would open the app and make it run normally. Why is this, and how can I make it so that it runs just by opening the app normally?

Thank you, and if you have any follow-up questions, let me know, and I will do my best to answer them.

New contributor

Jacob Barkin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật