1

I have a program written in Python 3.3 that needs to run on both PC's and Macs, preferably without requiring an installation of Python or any supporting modules. I know this question has been asked before, but I've tried py2exe, py2app, and cx_Freeze to no avail. I'm relatively new to the programming world, so perhaps I'm doing something wrong. My program is composed of four .py files containing GUI and logic classes, and it requires use of the xlrd, xlsxwriter, os.path, and tkinter modules.

The closest I've gotten to making this work is py2app, which generated a .app file that returned "GUI error" when run. Cx_Freeze generated a .app file that wouldn't run at all. I have both OS X 10.9 and Windows 8 at my disposal. Can someone break this down step by step, or refer me to a tutorial that does? Thank you very much for your help.

This is the simple setup.py file I used for cx_Freeze. I ran it with python3.3 setup.py bdist_mac from the Terminal.

application_title = "Index Calculator" 
main_python_file = "GUI.py" 

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

includes = ["atexit","re"]

setup(
        name = application_title,
        version = "1.0",
        description = "Calculates forest sustainability",
        options = {"build_exe" : {"includes" : includes }},
        executables = [Executable(main_python_file, base = base)])
user1251007
  • 15,891
  • 14
  • 50
  • 76
dcastello
  • 35
  • 8
  • 1
    What error do you get from the cx_Freeze application? Can you show the log from freezing it? – Thomas K Jan 07 '14 at 23:04
  • @ThomasK, I don't get any errors, but the .app file produced doesn't run. I'm not sure where I would find the log. Are you referring to the terminal output? I can also post the setup.py file I used, there may be an issue there. – dcastello Jan 08 '14 at 06:01
  • does it work for a [sample tkinter script](https://bitbucket.org/anthony_tuininga/cx_freeze/src/04ca56e81816/cx_Freeze/samples/Tkinter/?at=default)? – jfs Jan 08 '14 at 11:33
  • Yep, I mean the terminal output. As for the app, you might see some error messages if you go to the terminal and run `myapp.app/Contents/MacOS/myapp` (replacing myapp with the name of your application). – Thomas K Jan 08 '14 at 17:15
  • @ThomasK I tried to run the app using that path, but it was unable to find the directory. I looked into the package contents to see if I could find the problem. In the MacOS folder, there is no .exe file by the name of the application. Could that be why this won't run? – dcastello Jan 08 '14 at 20:02
  • @J.F.Sebastian I tried this with the sample tkinter script and ran into the exact same problem... Interesting. Is there an issue with the terminal command I used to start the process? – dcastello Jan 08 '14 at 20:12
  • It wouldn't have a .exe extension on a Mac. Let's break this down into steps: can you run `setup.py build_exe`? That should give you a `build/exe...` directory with a few files in, including an executable binary. Try running that in a terminal and see if it works. If it does, then the problem must be something to do with making the Mac .app. – Thomas K Jan 08 '14 at 22:40
  • @ThomasL The build directory contains maybe 20 files. If I run the executable by the name of my program module, it gets to the first import statement and then throws an error. In this case, that was `ImportError: No module named 'xlsxwriter'`. In setup.py, I named the program "Calculator" to be simple, but there's no executable by that name in build directory. – dcastello Jan 08 '14 at 23:38
  • Possible duplicate of [How do I compile my Python 3 app to an .exe?](http://stackoverflow.com/questions/17907258/how-do-i-compile-my-python-3-app-to-an-exe) – Cees Timmerman May 18 '17 at 14:30

0 Answers0