I'm on Ubuntu 16.04 and I've created a python script for my colleague - he has MacOS. Assume that he doesn't know anything about bash or python.

So I don't want to make him running this script from bash. I would like him just to double click on file to execute the script.

How would you do that?


#!/usr/bin/env python


chmod +x filename 

Doesn't work on my Ubuntu so I suppose it won't work on MacOS

This is a top of the script:

#!/usr/bin/env python
# coding=utf-8
import os
    import jinja2
except ImportError:
    import pip

EDIT: I can't access his Mac so either I have to give him clear instructions or create some executable.

  • Looks reasonable to me, why does it not work on Ubuntu? It should work on macOS, assuming the python executable in PATH has the required version and all the libraries are either installed or installable.
    – nohillside
    Commented Aug 9, 2017 at 10:35
  • I'm not sure. But even if I do this steps, when I click on file.py, it is opened in gedit (text editor).
    – Milano
    Commented Aug 9, 2017 at 10:43
  • That's a Linux issue then. As long as your friend doesn't have configured their Mac to open .py files in an editor you should be fine.
    – nohillside
    Commented Aug 9, 2017 at 11:56

2 Answers 2


You can simply rename the file and make it file extension "command" instead. Plus, you have to make it executable (like you do before with chmod +x). Simply name it "jinja.command", instead of "jinja.py" for example.

Then, you will see terminal window opened with text output (if you have one in your application), as far as the "program terminated" string.

  • Didn't help, still opening in gedit.
    – Milano
    Commented Aug 9, 2017 at 11:10
  • You should use the extension ".command" to execute files with console scripts for macOS only. The answer was about macOS, because originally you asked about mac. If you want the same thing, but for ubuntu, you should use another approach: askubuntu.com/questions/286621/…
    – AlexM
    Commented Aug 9, 2017 at 11:23
  • @MilanoSlesarik I'll add a Mac specific tool as another answer. It lets you keep your script set for all platforms and the Mac specific GUI separate.
    – bmike
    Commented Aug 9, 2017 at 12:05

You want a tool called Platypus. It provides very clear guidance on turning scripts into apps.

enter image description here

Platypus is a Mac OS X developer tool that creates native Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs. This is done by wrapping the script in an application bundle along with a native executable binary that runs the script.

  • Would this work on a directory library?
    – ʀ2ᴅ2
    Commented Aug 9, 2017 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .