3

All,

I have developed a python program that is controlled by a GUI developed in PyQt. This GUI file, which was later converted to python (using pyuic4) implements about 4 other python files including a "main file". How could I convert all of these into one "double - clickable" .exe file? NOTE: My program and GUI both work when I run my main file.

Regards

2 Answers 2

4

You can use cxFreeze to build executable: http://cx-freeze.sourceforge.net/.

However, there will be a lot of files, but you could use your app standalone.

Also, you should be accurate in module imports to reduce size of the build. My scripts (about 200KB) were built in 200MB monster (used SciPy and Qt4).

Example build scripts is attached:

#coding=utf-8

from cx_Freeze import setup, Executable

includes = ["atexit"] 

buildOptions = dict(
    create_shared_zip=False,
    append_script_to_exe=True,
    includes=includes
)

executables = [
    Executable(
        script='main.py',
        targetName='projectname.exe',
        base="Win32GUI" # THIS ONE IS IMPORTANT FOR GUI APPLICATION
    )
]

setup(
    name="ProjectName",
    version="1.0",
    description="",
    options=dict(build_exe=buildOptions),
    executables=executables
)
Sign up to request clarification or add additional context in comments.

7 Comments

"Win32GUI" would this be the same for me? seeing as I developed in QtDesigner for Windows 64 bit? Also, would I need to include the other files that are imported in my code into this? Or will it recognize them and manually combine all into one .exe as long as it is in the same directory?
Yes, i'm using 64bit system/python/qt4 too. You should to add (to buildOptions) files you want to become .exe. Python "import" dependencies will mostly be autoincluded by cxFreeze. However, there are some exceptions: - stackoverflow.com/questions/8765568/…; - 'scipy.special._ufuncs_cxx'; - 'scipy.sparse.csgraph._validation'; - 'scipy.sparse.linalg.dsolve'; - 'scipy.integrate.vode'; - 'scipy.integrate.lsoda'; - 'numpy.core.multiarray'; - maybe some more.
Awesome, I will test this out now. Is there a command/ certain flags youve found to work?
Sorry, not to 'buildOptions', obviously, but to 'executables'. Flags? Like what?
I gave you a link in previous comment. Simply add module name to 'includes' list.
|
0

There are many tools to convert Python applications to executable files. I recommend to use cx_Freeze: http://cx-freeze.readthedocs.org/en/latest/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.