0

I'm compiling and exe using py2exe

when I test the code running from cmd like this

C:\wdir\mvl-tryton-client\tryton-3.2.3\bin>python tryton

it works fine.

But when I run it after executing the generated installation I get:

Error DLL load failed: The specified procedure could not be found.

File "tryton\common\common.pyc", line 1341, in process
File "tryton\gui\main.pyc", line 878, in _set_preferences
File "tryton\gui\main.pyc", line 1049, in sig_win_menu
File "tryton\gui\window\view_form\screen\screen.pyc", line 95, in __init__
File "tryton\gui\window\view_form\screen\screen.pyc", line 364, in switch_view
File "tryton\gui\window\view_form\screen\screen.pyc", line 384, in load_view_to_load
File "tryton\gui\window\view_form\screen\screen.pyc", line 397, in add_view_id
File "tryton\gui\window\view_form\screen\screen.pyc", line 425, in add_view
File "tryton\gui\window\view_form\view\widget_parse.pyc", line 4, in <module>
File "tryton\gui\window\view_form\view\form_gtk\__init__.pyc", line 3, in <module>
File "tryton\gui\window\view_form\view\form_gtk\parser.pyc", line 537, in <module>
File "tryton\gui\window\view_form\view\form_gtk\fingerprint.pyc", line 11, in <module>
File "tryton\gui\window\view_form\view\form_gtk\fpenroll.pyc", line 9, in <module>
File "ctypes\__init__.pyc", line 10, in <module>
File "_ctypes.pyc", line 12, in <module>
File "_ctypes.pyc", line 10, in __load

my guess is some missing configuration in the setup.py, or a missing path to the ctypes lib, but I couldn't find any precise info in the docs.

Any help or hint is greatly appreciated. Thanks. Mariano

EDIT: here is the _ctypes.py. I tried to print the name and path variables. But when running the exe from the cmd it shows no output there.

def __load():
    import imp, os, sys
    try:
        dirname = os.path.dirname(__loader__.archive)
    except NameError:
        dirname = sys.prefix
    path = os.path.join(dirname, '_ctypes.pyd')
    #print "py2exe extension module", __name__, "->", path
    mod = imp.load_dynamic(__name__, path)
##    mod.frozen = 1
__load()
del __load
Marciano
  • 123
  • 4
  • 9

1 Answers1

0

Thanks for the comments guys. I solved it adding the ctypes and _ctypes packagaes to the includes in setup.py like this:

args['options'] = {
    'py2exe': {
        'optimize': 0,
        'bundle_files': 3,  # don't bundle because gtk doesn't support it
        'packages': [
            'encodings',
            'gtk',
            'pytz',
            'atk',
            'pango',
            'pangocairo',
            'gio',
            'ctypes',
            '_ctypes'
        ],
        'dll_excludes': [ "mswsock.dll", "powrprof.dll" ]
    }
}
Marciano
  • 123
  • 4
  • 9
  • Your question shows that py2exe already included the ctypes package (`__init__.pyc`) and included a wrapper to load the extracted `_ctypes.pyd` extension module via `imp.load_dynamic`. It's not clear what adding the names to `packages` changed. `_ctypes` isn't even a package. Have you asked about this on the [py2exe-users](https://lists.sourceforge.net/lists/listinfo/py2exe-users) list? – Eryk Sun Oct 30 '14 at 22:34
  • no, should I? The only way it went smoothly (after the ctypes became a requirement) was building the exe in windows 8, and installing in windows 8 and nowhere else. The one here is built on XP (because most of the computers where this will be installed use xp) and works on all platforms. Oh and haven't tried adding _ctypes only. But just ctypes didn't work either. – Marciano Oct 31 '14 at 15:24