Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS -noconsole resulting app wont launch #4804

Closed
richard-moss opened this issue Apr 10, 2020 · 6 comments
Closed

MacOS -noconsole resulting app wont launch #4804

richard-moss opened this issue Apr 10, 2020 · 6 comments
Labels
bug platform:OS X state:verify This needs to be verified - would be great if someone could write a test-case for

Comments

@richard-moss
Copy link

richard-moss commented Apr 10, 2020

Creating App bundle with '-w' on OSX - resulting app won't launch.

Pyinstaller: 3.5 and 3.6 (tried both)
Python: 3.7.5 (conda install)
Platform: OSX (Mojave 10.14.1)

When creating a mac application bundle (-w) option, there are not problems building, but the result app won't launch. In console mode, either --onefile or not, there are no problems. No warnings during build. Directly launching the executable out of the mac application bundle launches app without problems.

Tried launching app bundle directly from cmd line, and no error or messages are reported, but the app has the same (ie won't launch) behavior.

Problem seen both with my app, and simple test app (included below)

Checked 'when things go wrong' and couldn't find anything I didn't already try (except for trying latest dev version of pyinstaller).

  • when built as console app: no problems
  • when launching the Mac app executable directly from the the app/Contents bundle: no problems
  • I checked mac console logs, and couldn't find any clues as to what is wrong

The problem was only apparent when attempting to launch the .app bundle directly.

Simple test app:

rom tkinter import *
from tkinter import ttk
from tkinter import messagebox
 
 
class Feedback:
 
    def __init__(self, mainframe):
        mainframe.title('Add Your Comment')
        mainframe.resizable(False, False)
        mainframe.configure(background='#f7f7f7')
 
        self.style = ttk.Style()
        self.style.configure('TFrame', background='#f7f7f7')
        self.style.configure('TButton', background='#e1d8b9')
        self.style.configure('TLabel', background='#f7f7f7', font=('Arial', 12))
        self.style.configure('Header.TLabel', font=('Arial', 18, 'bold'))
 
        self.header_frame = ttk.Frame(mainframe)
        self.header_frame.pack()
 
        ttk.Label(self.header_frame, text='blah').grid(row=0, column=0, rowspan=2)
        ttk.Label(self.header_frame, text='Comment App', style='Header.TLabel').grid(row=0, column=1)
        ttk.Label(self.header_frame, wraplength=300,
                  text=(
                      'Add your name, email, and comment, then click submit to add your comment.  Click clear if you make a mistake.')).grid(
            row=1, column=1)
 
        self.content_in_frame = ttk.Frame(mainframe)
        self.content_in_frame.pack()
 
        ttk.Label(self.content_in_frame, text='Name:').grid(row=0, column=0, padx=5, sticky='sw')
        ttk.Label(self.content_in_frame, text='Email:').grid(row=0, column=1, padx=5, sticky='sw')
        ttk.Label(self.content_in_frame, text='Comments:').grid(row=2, column=0, padx=5, sticky='sw')
 
        self.comment_name = ttk.Entry(self.content_in_frame, width=24, font=('Arial', 10))
        self.comment_email = ttk.Entry(self.content_in_frame, width=24, font=('Arial', 10))
        self.comments = Text(self.content_in_frame, width=50, height=10, font=('Arial', 10))
 
        self.comment_name.grid(row=1, column=0, padx=5)
        self.comment_email.grid(row=1, column=1, padx=5)
        self.comments.grid(row=3, column=0, columnspan=2, padx=5)
 
        ttk.Button(self.content_in_frame, text='Submit',
                   command=self.submit).grid(row=4, column=0, padx=5, pady=5, sticky='e')
        ttk.Button(self.content_in_frame, text='Clear',
                   command=self.clear).grid(row=4, column=1, padx=5, pady=5, sticky='w')
 
    def submit(self):
        self.clear()
        messagebox.showinfo(title='Comment info', message='Thanks for your comment!')
 
    def clear(self):
        self.comment_name.delete(0, 'end')
        self.comment_email.delete(0, 'end')
        self.comments.delete(1.0, 'end')


def main():
    root = Tk()
    root.geometry('500x400')
    feedback = Feedback(root)
    root.mainloop()
 
 
if __name__ == '__main__': main()
@Legorooj Legorooj added bug state:verify This needs to be verified - would be great if someone could write a test-case for platform:OS X labels Apr 11, 2020
@R-YaTian
Copy link

Same issue then
Pyinstaller: 3.6
Python: 3.7.6 (pip install)
Platform: Catalina(macOS 10.15.4)

@felixchenier
Copy link

Hello
I have this same issue on macOS Catalina.
48 INFO: PyInstaller: 3.6
48 INFO: Python: 3.7.7 (conda)
56 INFO: Platform: Darwin-19.4.0-x86_64-i386-64bit

@mesca
Copy link

mesca commented May 20, 2020

Same here...
62 INFO: PyInstaller: 4.0.dev0
62 INFO: Python: 3.7.7 (conda)
71 INFO: Platform: Darwin-19.4.0-x86_64-i386-64bit

@adamurban
Copy link

This is likely a Tcl bug, but could also be related to file reading/writing and the OS X sandbox. Do not use —onefile; this will break everything on recent macOS builds as it tries to extract things to a tmp folder and run them from there, which the new mac security mode disallows.

If you’re reading or writing files from relative paths, make sure that you change directories into something sane.

Also, it is a good idea to sign (and ideally, notarize) your app so that it clears the macOS gatekeeper checks.

The best answer though, unfortunately, is to not use Tkinter for OS X apps. I’ve found that pyside2 / Qt works much better / is better supported.

@csatt
Copy link

csatt commented Oct 1, 2020

This may be Issue #3820.

It is useful in debugging this kind of case to put your code in a "try" and in the "except" write the traceback to a file and then open that file in your editor.

See: #3820 (comment)

@rokm
Copy link
Member

rokm commented Oct 5, 2020

The onedir/onefile build working but application bundle not working is due to the issue explained in #3820 and addressed by #5175. I've tried the provided test program, and it seems to open as expected now.

@rokm rokm closed this as completed Oct 5, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug platform:OS X state:verify This needs to be verified - would be great if someone could write a test-case for
Projects
None yet
Development

No branches or pull requests

8 participants