1. Ronald Oussoren
  2. py2app
  3. Issues


Issue #74 duplicate

pyqt example doesn't work

Sebastian Krysmanski
created an issue

I installed py2app via sip and pyqt via homebrew. Running the pyqt examples ("hello_app" and "view_app") directly from the command line works (at least if an empty window means "working" for the "view_app").

I create the app with:

python setup.py py2app

Everything seems to work fine but when I try to open the app, I just get an error window (see attached screenshot). The console just says:

"02.11.12 10:59:37,894 main[4012]: main Error"

When trying to open the app from the command line (open -a dist/main.app), I just get:

"Unable to find application named 'dist/main.app'"

Comments (11)

  1. Ronald Oussoren repo owner

    Using the latter command-line also shows the stdout/stderr streams of the application in the Terminal window, that should give a hint about why the application doesn't start.

  2. Sebastian Krysmanski reporter

    Here's the output:

    $ dist/main.app/Contents/MacOS/main 
    Traceback (most recent call last):
      File "/Users/manski/Documents/Programmieren/Python/py2app/examples/PyQt/view_app/dist/main.app/Contents/Resources/__boot__.py", line 63, in <module>
      File "/Users/manski/Documents/Programmieren/Python/py2app/examples/PyQt/view_app/dist/main.app/Contents/Resources/__boot__.py", line 58, in _run
        exec(compile(source, path, 'exec'), globals(), globals())
      File "/Users/manski/Documents/Programmieren/Python/py2app/examples/PyQt/view_app/dist/main.app/Contents/Resources/main.py", line 1, in <module>
        from PyQt4.QtCore import QUrl
      File "PyQt4/QtCore.pyc", line 18, in <module>
      File "PyQt4/QtCore.pyc", line 15, in __load
    ImportError: '/usr/lib/python2.7/lib-dynload/PyQt4/QtCore.so' not found
    2012-11-02 11:25:08.299 main[4505:707] main Error
  3. Ronald Oussoren repo owner

    That's not right, a standalone application should not reference /usr/lib/python2.7, but should load QtCore.so from the application bundle.

    Are you sure that you are actually using the homebrew python? I have homebrew on my machine and the example works there (that is, it launches; the example itself doesn't actually do anything useful)

  4. getzen

    I don't know if this will help or not, but I ran into the same "ImportError: '/usr/lib/python2.7/lib-dynload/PyQt4/QtCore.so' not found" when trying to package a simple PySide app. I was using Apple's system 2.7 python.

    I fixed it by installing 2.7 from python.org, adding the following shebang to my PySide script and to the py2applet-generated setup.py:

    #!/Library/Frameworks/Python.framework/Versions/2.7/bin/python Then, I made setup.py executable with: chmod a+x setup.py

    and invoked it with: ./setup.py py2app

    That did the trick. The app appears to run just fine. (I say "appears to" since I haven't tried to run it on a virgin system yet.)

  5. DanHorner

    This sounds like the same symptom I just reported in issue #76. The system python has a lib-dynload directory that obscures the search for your extension. Maybe the python.org build doesn't?

    You could try building with system python and the patched util.py from #76. Not sure if that's the right solution but it's a solution.

  6. Ronald Oussoren repo owner

    I'm confused. When I install PyQt through homebrew it installs its own copy of Python as well.

    I can reproduce the issue using a hack:

    $ export PYTHONPATH=/opt/homebrew/lib/python2.7/site-packages
    $ /usr/bin/python setup.py py2app

    I consider this a hack because homebrew builds x86_64 only binaries while the system python supports i386 as well. There might be other differences.

    Anyway, Dan is correct: this is the same issue as #76: the lib-dynload inside the package is later on sys.path than the lib-dynload of the system python and that's why the loader cannot find the Qt extension.

    I'm closing this issue and will fix issue #76 based on the patch of Dan.

  7. Log in to comment