Shital
Shital

Reputation: 169

problem in executable created with py2exe

I have an application written in python which uses pygtk to built GUI, also some glade files are included for window building.

My problem is my application works fine when i run it from cmd, but when i create an exe with py2exe the application doesn't start, but it creates the empty log file which i am writing in application for logs.

my setup.py looks like :

from distutils.core import setup
import os
import pygtk
import py2exe

setup(
name = 'ABC',
description = 'blah blah blah',
author = 'XYZ',
version = '0.1',

windows = [
              {
                  'script': 'filename.py',
                  'icon_resources': [(1, "logo.ico")],
              }
          ],


options = {
              'py2exe': {
                  'packages':'encodings',
                  'includes': 'cairo, pango, pangocairo, atk, gobject,gio',
              }
          },
data_files=[
               'logo.png', 'bg.png', 'completed.png', 'down.png','up.png',
               'processing.gif', 'cygcrypto-0.9.8.dll', 'cyggcc_s-1.dll', 
               'cygiconv-2.dll', 'cygpopt-0.dll', 'cygssp-0.dll', 'cygwin1.dll',
               'cygz.dll', 'prog.exe','prog2.exe', 'prog3.exe',
               'Login.glade', 'settings_lib.glade', 
               'Microsoft.VC90.CRT.manifest', 'msvcm90.dll','etc.zip',
               'lib.zip', 'msvcp90.dll', 'msvcr90.dll', 'share.zip'
           ])  

What could be the problem?

Upvotes: 0

Views: 356

Answers (1)

Marc Abramowitz
Marc Abramowitz

Reputation: 3577

I had problems like this too quite a few times when using tools like py2exe and py2app.

IIRC, many times it was caused by the Python process's working directory being something very different when the .exe is double-clicked. You may want to add some code to the startup of your Python program that logs the value of os.getcwd()

The other thing that is tricky is that you have to make sure that py2exe bundles in all the Python modules that your program is using. When running from the command-line, you're using a Python that has all those modules. When double-clicking the .exe, you're using a Python that is bundled into the executable along with modules that you've explicitly listed in setup.py -- it's very easy to miss one. To find this, you could put try/except clauses around your imports and then logging the ImportError exceptions to a file.

Upvotes: 1

Related Questions