Question

Past day has basically been a continuous frustration. I'm trying to create my first pyQt5 application and freeze it to OSX app. Here short chronology of my efforts so far:

  1. Noticed that PyQt5 install is only for Python3. Installed Python3 and pyQt via Homebrew.
  2. Developed application. Everything works when launched from PyCharm.
  3. Installed cx_freeze from source to Python3 since Pycharm's pip installer failed in task.
  4. Trying to freeze the application with cx_freeze only to get syntax error. Resolved it with following advice applied to pyQt5: SyntaxError when using cx_freeze on PyQt app
  5. Checked tutorial for cx_freeze: http://www.pythonschool.net/cxfreeze_mac/ and created a setup.py by the example:

    application_title = "simple_PyQt4" #what you want to application to be called
    main_python_file = "main.py" #the name of the python file you use to run the program
    
    import sys
    
    from cx_Freeze import setup, Executable
    
    base = None
    if sys.platform == "win32":
        base = "Win32GUI"
    
    includes = ["atexit","re"]
    
    setup(
        name = application_title,
        version = "0.1",
        description = "Sample cx_Freeze PyQt4 script",
        options = {"build_exe" : {"includes" : includes }},
        executables = [Executable(main_python_file, base = base)])
    
  6. Run the cx_freeze with "bdist_mac" parameter. This time .app file was generated. However, it doesn't launch. Can't see any errors or information anywhere. Just doesn't launch at all when clicked.

At this point I'm getting really tired of all of this so please help. If you can, please help me either: 1. Install PyQt5 to Python2.7 with Homebrew (tried, couldn't figure it out) so that I can use packaking tools compatible with Python2. 2. Get the freezing process to work properly. If possible give detailed explanations, I'm new to these tools.

I'm also interested in hearing how people are supposed to deploy standalone applications with pyQt5 since the process seems anything other than straightforward.

EDIT: I ran the result "main" in folder as suggested by ThomasK. I got following error but have no idea what it means:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/cx_Freeze-4.3.2-py3.3-macosx-10.9-x86_64.egg/cx_Freeze/initscripts/Console3.py", line 27, in <module>
    exec(code, m.__dict__)
  File "main.py", line 8, in <module>
  File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py", line 1565, in _find_and_load
    return _find_and_load_unlocked(name, import_)
  File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py", line 1512, in _find_and_load_unlocked
    _call_with_frames_removed(import_, parent)
  File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py", line 313, in _call_with_frames_removed
    return f(*args, **kwds)
  File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py", line 1565, in _find_and_load
    return _find_and_load_unlocked(name, import_)
  File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py", line 1529, in _find_and_load_unlocked
    raise exc
ImportError: No module named 'ui'

On main.py I have this import on line 8:

from ui.main import Ui_MainWindow

I have all the .ui files and their .py counterparts at folder named "ui" in my project directory.

EDIT: Output of the freezing process: http://pastebin.com/RR9pNGfR EDIT: And my project schema: http://pastebin.com/HmsdNXEb

No correct solution

OTHER TIPS

I don't know how far the original poster ever got in solving their problem, and the pastebins referenced are long since deleted so there's not a lot of supplementary material, but the latest version of those cx_freeze instructions at pythonschool, updated on 2014-08-27 (after this question), says:

Unfortunately the current version of cx_Freeze on Mac OS X does not play particularly nicely with Python versions that have been installed from Python.org or PyQt if you have installed it previously using our instructions. Therefore, to ensure that cx_Freeze installs successfully you will need to install Python and PyQt using a package manager called MacPorts.

So, that may have been the problem all along. Installing Python3 and PyQt "via Homebrew" sounds like it may have also resulted in a problematic configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top