py2app problems, using Enthought Python Distribution

Issue #137 new
David Goldenberg created an issue

Hi, I am trying to use py2app to build a standalone for a python script that uses the matplotlib, numpy and scipy modules, using an up to date version of the Enthoought Python Distribution (EPD) with Python 2.73, 32-bit. The setuptools and distribute modules included with EPD are both version 0.6.49, but I have manually updated setutptools to 2.2 and distribute to 0.7.3.

This is being done on a Mac with OS X Mountain Lion (10.8.5).

With the alias option for py2app, the application builds and runs fine, but when I try to build a standd-alone application, I have run into several problems, some of which I think that I fixed myself, but the final app fails. The problems I have run into, and my attempted solutions are described below.

  1. This py2app build hsangs with

    File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/sympy/mpmath/libmp/", line 1 exec_ = exec ^ SyntaxError: invalid syntax

But, can get past this with > python py2app --exclude sympy

  1. Then it hangs with:

File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/py2app-0.8-py2.7.egg/py2app/", line 1319, in copy_python_framework fwkfiles.append( NameError: global name 'fwkfiles' is not defined

I tracked this down to:

    fmwkfiles = [
    if '_sysconfigdata' not in sys.modules:
           'lib/%s/%s/Makefile'%(pydir, configdir)

in, where it looks like fwkfiles should be fmwkfiles. Changing "fwkfiles.append" to "fmwkfiles.append" allows the build to continue.

  1. Then, it hangs on:

    File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/macholib-1.6-py2.7.egg/macholib/",
    line 49, in locate loader=loader.filename) TypeError: dyld_find() got an unexpected keyword argument 'loader'

The app builds using --debug-skip-macholib option but, the application fails with:

2/27/14 1:38:29.355 PM revinhib[35736]: A Python runtime not could be located.  You may need to install a framework build of Python,
 or edit the PyRuntimeLocations array in this application's Info.plist file.

I tracked the problem with macholib back to the definition of dyld_find() in

def dyld_find(name, executable_path=None, env=None, loader_path=None):

I changed line 49 in macOGraph from loader=loader.filename)

to loader_path=loader.filename)

Now, py2app runs and generates an app, but

  1. The built app fails with:

Traceback (most recent call last): File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 393, in <module> _run() File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 336, in _run exec(compile(source, path, 'exec'), globals(), globals()) File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 5, in <module> import numpy as np File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 168, in <module> from . import add_newdocs File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 13, in <module> from numpy.lib import add_newdoc File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 18, in <module> from .polynomial import File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 19, in <module> from numpy.linalg import eigvals, lstsq, inv File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 50, in <module> from .linalg import File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/", line 29, in <module> from numpy.linalg import lapack_lite, _umath_linalg ImportError: dlopen(/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/, 2): Library not loaded: @rpath/lib/libmkl_intel.dylib Referenced from: /Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/ Reason: image not found 2014-02-27 14:17:34.103 revinhib[36339:303] revinhib Error

Any help would be greatly appreciated!

Comments (7)

  1. Ronald Oussoren repo owner

    Could you test with the version of py2app from the repository? That should at least fix the "fwkfiles" bug, and likely the dyld_find problem as well.

    The first problem you mention is issue #132, I'm still thinking about a fix for that one.

  2. David Goldenberg reporter

    I just tried this, after installing both py2app and modulegraph from the repository. I get the following error when trying to generate the setup file with py2applet:

    File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/modulegraph-0.12-py2.7.egg/modulegraph/", line 631 yield n SyntaxError: 'return' with argument inside generator

    Thanks, David

  3. Jon Peirce

    I'm having a similar issue. Updating to use the repos versions (py2app, modulegraph and macholib all from your bitbucket) did fix the fwkfiles error, but I was still getting the error with dydl_find() and the unknown loader.

    David's fix of changing to loader to loader_path fixed it for me though and I didn't have any subsequent issues.

    cheers Jon

  4. bonosergi

    Same issue here. I was not able to build my app using py2app (0.9) on Yosemite 10.10.2. Using Python2.7.9 installed via Homebrew. With all these modules and versions installed via pip:

    altgraph (0.12)
    macholib (1.7)
    matplotlib (1.4.3)
    mock (1.0.1)
    modulegraph (0.12)
    nose (1.3.4)
    numpy (1.9.2)
    pip (6.0.8)
    py2app (0.9)
    pyparsing (2.0.3)
    python-dateutil (2.4.1)
    pytz (2014.10)
    scipy (0.15.1)
    setuptools (12.0.5)
    six (1.9.0)

    I also fixed the dydl_find() error editing line 49 in as said above and now the app is build with no issues.

    However, the app is not ploting correctly 3D surfaces from matplotlib 3D toolkit. Not related with py2app I assume.

    Cheers, Sergi

  5. Rob Campbell

    I also had to change in the way described above to get my code to compile, although the built application crashes on startup.

  6. Ehsan Azarnasab

    Changing loader to loader_path also fixed the build issue for me! I wonder when the PyPi package will be updated.

  7. Sh Esh

    I came across the same issue and edited line 49 in I could make .app, but got an error when it's opened. The error is:

    ImportError: dlopen(/Users/S/Python_app/dist/, 2): Library not loaded: @loader_path/libwx_osx_cocoau-

    I used wxpython for GUI.

  8. Log in to comment