Mahadeva
Mahadeva

Reputation: 1647

Creating a python executable using py2exe

I tried to create executable of my File NewExistGUI2.py, where GUI is made using wxpython. The file depends upon other two files localsettings.py and Tryone.py. I referred to py2exe documentation, and created a setup.py file as:

from distutils.core import setup    
import py2exe
    
    setup(name = 'python eulexistdb module',
        version = '1.0',
        description = 'Python eXistdb communicator using eulexistdb module',
        author = 'Lorem Ipsum',
        py_modules = ['NewExistGUI2','localsettings','Tryone']
        )

and compiled the program in command line using

python setup.py py2exe

But I didn't got any .exe file of the main program NewExistGUI2.py in dist folder created. What Should I do now?

Upvotes: 0

Views: 2085

Answers (1)

Gabriel Samfira
Gabriel Samfira

Reputation: 2765

I woul recommend you create a module (ExistGUI) with the following structure:

ExistGUI
\_ __init__.py
|_ localsettings.py
|_ Tryone.py
bin
\_ NewExistGUI2.py

Your init.py should have:

from . import localsettings, Tryone

__version__ = 1.0

Your setup.py should look something like:

from setuptools import setup, find_packages
import ExistGUI
import py2exe

setup(
     name = 'ExistGUI',
     version = ExistGUI.__version__,
     console=['bin/NewExistGUI2.py'],
     description = 'Python eXistdb communicator using eulexistdb module',
     author = 'Sarvagya Pant',
     packages= find_packages(),
     scripts=['NewExistGUI2.py',],
     py_modules = ['localsettings','Tryone'],
     include_package_data=True,
     zip_safe=False,
)

Then run python setup.py py2exe. Make sure you include any requirements for your module in setup.py. Also, remove the previously generated dist directory, just to be sure.

Hope this helps.

Upvotes: 1

Related Questions