david
david

Reputation: 6785

How to turn Python program into executable file

I apologize for such a basic question. I've done some research online and still cannot figure out for the life of me how to turn a python folder into something like an actual app I can open in OS X. I am using Mac OS X, Terminal and Coderunner for my Python project.

Upvotes: 0

Views: 280

Answers (2)

beroe
beroe

Reputation: 12316

Typically you would make the script executable by putting

#!/usr/bin/env python

as the first line, and then in a terminal window typing

chmod u+x myscript.py

You might also want to put it in a special scripts folder and then add that to your PATH by editing .bash_profile. (I am putting a lot of buzz-words here to help you find the tutorials explaining how these things work.)

You can wrap your script into an Automator object if you want to try running it that way, but in the long run you will be better off getting comfortable working in a terminal window.

It would also help to know what your app does: Process files, generate a GUI, do a calculation, etc...

Upvotes: 0

Nicholas Riley
Nicholas Riley

Reputation: 44321

Here are a few options:

  • Platypus is not Python-specific. It lets you wrap a simple GUI around a command line tool.
  • py2app is Python-specific and a good choice if you have a GUI, or need to run in the background.
  • PyInstaller is similar to py2app but cross-platform; I've never used it, so I don't know how well it works.

The right choice depends on what your program does; who is the expected audience — do you need to redistribute it, if so how, and so forth. If you want to make the application entirely self-contained — not dependent on anything else beyond the OS — then things get more complicated (though certainly not insoluble; there are several commercial Mac desktop apps written in Python.)

Upvotes: 3

Related Questions