1. Ronald Oussoren
  2. py2app

Issues

Issue #137 new

py2app problems, using Enthought Python Distribution

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/exec_py3.py", line 1 exec_ = exec ^ SyntaxError: invalid syntax

But, can get past this with > python setup.py 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/build_app.py", line 1319, in copy_python_framework fwkfiles.append( NameError: global name 'fwkfiles' is not defined

I tracked this down to:

    fmwkfiles = [
        os.path.basename(info['name']),
        'Resources/Info.plist',
        'include/%s/pyconfig.h'%(includedir),
    ]
    if '_sysconfigdata' not in sys.modules:
        fwkfiles.append(
           'lib/%s/%s/Makefile'%(pydir, configdir)
        )

in build_app.py, 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/MachOGraph.py",
    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 dyld.py:

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/revinhib.app/Contents/Resources/boot.py", line 393, in <module> _run() File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/boot.py", line 336, in _run exec(compile(source, path, 'exec'), globals(), globals()) File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/revinhib.py", line 5, in <module> import numpy as np File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/init.py", line 168, in <module> from . import add_newdocs File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/lib/init.py", line 18, in <module> from .polynomial import File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/lib/polynomial.py", line 19, in <module> from numpy.linalg import eigvals, lstsq, inv File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/linalg/init.py", line 50, in <module> from .linalg import File "/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/linalg/linalg.py", line 29, in <module> from numpy.linalg import lapack_lite, _umath_linalg ImportError: dlopen(/Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/linalg/lapack_lite.so, 2): Library not loaded: @rpath/lib/libmkl_intel.dylib Referenced from: /Users/davidg/Dropbox/work-db/programmingProjects/revInhibFit/dist/revinhib.app/Contents/Resources/lib/python2.7/numpy/linalg/lapack_lite.so 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. 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

  3. 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 MachOGraph.py 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

  4. Sh Esh

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

    ImportError: dlopen(/Users/S/Python_app/dist/GUIv2.app/Contents/Resources/lib/python3.4/lib-dynload/wx/_core.so, 2): Library not loaded: @loader_path/libwx_osx_cocoau-3.0.0.3.0.dylib
    

    I used wxpython for GUI.

  5. Log in to comment