How to make executable .py file (for non-programmer)

bashpythonterminal

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?

Adding:

#!/usr/bin/env python

alongside

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
try:
    import jinja2
except ImportError:
    import pip
    pip.main(['install','jinja2'])

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

Best Answer

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.