Error with standalone wxpython app created with py2app

I am trying to create a standalone Mac GUI app.

I used wxPython (wxpython-phoenix 3.0.3) to create the GUI.

I am trying to use py2app (0.14) to create a standalone app that can be used on a different machine not requiring a python installation.

The wxPython works fine by itself on the machine where it was created (MacOS Sierra, virtual environment in miniconda python).

I am able to compile the app using py2app, but the app does not work. When I run it from the command line, I get the following error:

Traceback (most recent call last):

File “/repos/ct/dist/CtAnnotator.app/Contents/Resources/boot.py”, line 386, in

_run()

File “/repos/ct/dist/CtAnnotator.app/Contents/Resources/boot.py”, line 370, in _run

exec(compile(source, path, 'exec'), globals(), globals())

File “/repos/ct/dist/CtAnnotator.app/Contents/Resources/CtAnnotator.py”, line 2, in

import wx

File “/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/init.py”, line 17, in

from wx.core import *

File “/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/core.py”, line 12, in

from ._core import *

ImportError: dlopen(/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/_core.so, 2): Symbol not found: _iconv

Referenced from: /repos/ct/dist/CtAnnotator.app/Contents/MacOS/…/Resources/lib/python2.7/wx/libwx_baseu-3.0.0.3.0.dylib

Expected in: /repos/ct/dist/CtAnnotator.app/Contents/MacOS/…/Frameworks/libiconv.2.dylib

in /repos/ct/dist/CtAnnotator.app/Contents/MacOS/…/Resources/lib/python2.7/wx/libwx_baseu-3.0.0.3.0.dylib

2017-07-14 00:46:55.453 CtAnnotator[38476:1598471] CtAnnotator Error

Here’s my build python script:

#!/usr/bin/env python

“”"

build_CtAnnotator.py - script for building CtAnnotator

Usage:

% python build_CtAnnotator.py py2app

“”"

from setuptools import setup

import sys

from distutils.core import setup

sys.setrecursionlimit(20000)

APP = [‘CtAnnotator.py’]

PACKAGES = [‘wx’, ‘os’, ‘dicom’, ‘operator’, ‘cv2’, ‘numpy’, ‘cPickle’]

OPTIONS = {‘argv_emulation’: True,

       'plist': {'PyRuntimeLocations': ['/opt/localdepth/localdepth/localdepth/localdepth/localdepth/localdepth/miniconda2/envs/app-env/lib/libpython2.7.dylib']},

       'packages': ['wx'],

      }

DATA_FILES = []

setup(app=APP,

  data_files=DATA_FILES,

  options={'py2app': OPTIONS},

  setup_requires=['py2app'],

 )

The reason for the deep miniconda installation is to avoid the “Mach-O header is too large to relocate in” error.

See: http://py2app.readthedocs.io/en/latest/faq.html

Can someone help me figure out how to solve this problem?

Thanks!

Hi, Oksana,

I am trying to create a standalone Mac GUI app.

I used wxPython (wxpython-phoenix 3.0.3) to create the GUI.

I am trying to use py2app (0.14) to create a standalone app that can be used
on a different machine not requiring a python installation.

The wxPython works fine by itself on the machine where it was created (MacOS
Sierra, virtual environment in miniconda python).

I am able to compile the app using py2app, but the app does not work. When I
run it from the command line, I get the following error:

Are you trying to run the binary in the same environment or a different machine?

Thank you.

···

On Fri, Jul 14, 2017 at 4:13 AM, Oksana Meledin <oksanameledin@gmail.com> wrote:

Traceback (most recent call last):
  File "/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line
386, in <module>
    _run()
  File "/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line
370, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/repos/ct/dist/CtAnnotator.app/Contents/Resources/CtAnnotator.py",
line 2, in <module>
    import wx
  File
"/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/__init__.py",
line 17, in <module>
    from wx.core import *
  File
"/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/core.py",
line 12, in <module>
    from ._core import *
ImportError:
dlopen(/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/_core.so,
2): Symbol not found: _iconv
  Referenced from:
/repos/ct/dist/CtAnnotator.app/Contents/MacOS/../Resources/lib/python2.7/wx/libwx_baseu-3.0.0.3.0.dylib
  Expected in:
/repos/ct/dist/CtAnnotator.app/Contents/MacOS/../Frameworks/libiconv.2.dylib
in
/repos/ct/dist/CtAnnotator.app/Contents/MacOS/../Resources/lib/python2.7/wx/libwx_baseu-3.0.0.3.0.dylib
2017-07-14 00:46:55.453 CtAnnotator[38476:1598471] CtAnnotator Error

Here's my build python script:

#!/usr/bin/env python
"""
build_CtAnnotator.py - script for building CtAnnotator

Usage:
    % python build_CtAnnotator.py py2app
"""
from setuptools import setup
import sys
# from distutils.core import setup

sys.setrecursionlimit(20000)

APP = ['CtAnnotator.py']
PACKAGES = ['wx', 'os', 'dicom', 'operator', 'cv2', 'numpy', 'cPickle']
OPTIONS = {'argv_emulation': True,
           'plist': {'PyRuntimeLocations':
['/opt/localdepth/localdepth/localdepth/localdepth/localdepth/localdepth/miniconda2/envs/app-env/lib/libpython2.7.dylib']},
           'packages': ['wx'],
          }
DATA_FILES =

setup(app=APP,
      data_files=DATA_FILES,
      options={'py2app': OPTIONS},
      setup_requires=['py2app'],
     )

The reason for the deep miniconda installation is to avoid the "Mach-O
header is too large to relocate in" error.
See: Frequently Asked Questions — py2app 0.28.8 documentation

Can someone help me figure out how to solve this problem?

Thanks!

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Also, check this thread: import universe gives Symbol not found: _iconv · Issue #139 · openai/universe · GitHub

···

On Fri, Jul 14, 2017 at 11:47 AM, Igor Korot <ikorot01@gmail.com> wrote:

Hi, Oksana,

On Fri, Jul 14, 2017 at 4:13 AM, Oksana Meledin <oksanameledin@gmail.com> wrote:

I am trying to create a standalone Mac GUI app.

I used wxPython (wxpython-phoenix 3.0.3) to create the GUI.

I am trying to use py2app (0.14) to create a standalone app that can be used
on a different machine not requiring a python installation.

The wxPython works fine by itself on the machine where it was created (MacOS
Sierra, virtual environment in miniconda python).

I am able to compile the app using py2app, but the app does not work. When I
run it from the command line, I get the following error:

Are you trying to run the binary in the same environment or a different machine?

Thank you.

Traceback (most recent call last):
  File "/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line
386, in <module>
    _run()
  File "/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line
370, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/repos/ct/dist/CtAnnotator.app/Contents/Resources/CtAnnotator.py",
line 2, in <module>
    import wx
  File
"/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/__init__.py",
line 17, in <module>
    from wx.core import *
  File
"/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/core.py",
line 12, in <module>
    from ._core import *
ImportError:
dlopen(/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/wx/_core.so,
2): Symbol not found: _iconv
  Referenced from:
/repos/ct/dist/CtAnnotator.app/Contents/MacOS/../Resources/lib/python2.7/wx/libwx_baseu-3.0.0.3.0.dylib
  Expected in:
/repos/ct/dist/CtAnnotator.app/Contents/MacOS/../Frameworks/libiconv.2.dylib
in
/repos/ct/dist/CtAnnotator.app/Contents/MacOS/../Resources/lib/python2.7/wx/libwx_baseu-3.0.0.3.0.dylib
2017-07-14 00:46:55.453 CtAnnotator[38476:1598471] CtAnnotator Error

Here's my build python script:

#!/usr/bin/env python
"""
build_CtAnnotator.py - script for building CtAnnotator

Usage:
    % python build_CtAnnotator.py py2app
"""
from setuptools import setup
import sys
# from distutils.core import setup

sys.setrecursionlimit(20000)

APP = ['CtAnnotator.py']
PACKAGES = ['wx', 'os', 'dicom', 'operator', 'cv2', 'numpy', 'cPickle']
OPTIONS = {'argv_emulation': True,
           'plist': {'PyRuntimeLocations':
['/opt/localdepth/localdepth/localdepth/localdepth/localdepth/localdepth/miniconda2/envs/app-env/lib/libpython2.7.dylib']},
           'packages': ['wx'],
          }
DATA_FILES =

setup(app=APP,
      data_files=DATA_FILES,
      options={'py2app': OPTIONS},
      setup_requires=['py2app'],
     )

The reason for the deep miniconda installation is to avoid the "Mach-O
header is too large to relocate in" error.
See: Frequently Asked Questions — py2app 0.28.8 documentation

Can someone help me figure out how to solve this problem?

Thanks!

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Igor,

Thanks for taking a look at my issue.

I’m trying to run it on the same machine for now. The eventual goal is to run it on a different mac without a python development environment.

I did take a look at https://github.com/openai/universe/issues/139. The issue is similar to mine but not the same. I am not trying to “import universe”. Rather I am doing “import wx”.

As your app works OK with wx Python itself, you may get more help with the py2app part of it from the pythonmac-SIG list which often has discussions about py2app and its development.

Pythonmac-SIG maillist - Pythonmac-SIG@python.org
https://mail.python.org/mailman/listinfo/pythonmac-sig

···

On Friday, July 14, 2017 at 4:21:05 PM UTC+1, Oksana Meledin wrote:

I am trying to create a standalone Mac GUI app.

I used wxPython (wxpython-phoenix 3.0.3) to create the GUI.

I am trying to use py2app (0.14) to create a standalone app that can be used on a different machine not requiring a python installation.

The wxPython works fine by itself on the machine where it was created (MacOS Sierra, virtual environment in miniconda python).

I am able to compile the app using py2app, but the app does not work. When I run it from the command line, I get the following error:


Regards
David Hughes
Forestfield Software