Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

A .pyw file is a Python script that launches an application with a user interface, without a console window. I want to be able to double click a .pyw file in Finder in OSX to open that application, but when I right click and select Open With->Other I'm not allowed to select /usr/bin/python. It is greyed out even though I've enabled "All applications".

I assume this is because it will only let me select .app directories. It there any way to work around this so that I can open Python GUI applications without the terminal?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use Automator to create an application like this:

Automator workflow for pythonw

The script in Run Shell Script above is (notice Pass Input as arguments):

/usr/bin/python "$@" > /dev/null 2>&1
exit 0

When saving it choose File Format Application (not Workflow). You could save it as /Applications/pythonw.

Then select a pyw file, press Command-I and select Open with>Other... and /Applications/pythonw. Then click Change All... and confirm with OK. The Get Info window should look like this:

Get Info pyw file

Now double click the pyw file and accept the warning (only the first time).

I've tested it with gui1.pyw:

from Tkinter import Label
widget = Label(None, text='Hello GUI world!') 
widget.pack()
widget.mainloop()

and worked like a charm.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.