Bundling with cx_freeze

815 views
Skip to first unread message

Jerry Prawiharjo

unread,
May 21, 2014, 5:37:59 PM5/21/14
to pyqt...@googlegroups.com
Hi all,
 
I'm having difficulty now trying to bundle my application with cx_freeze.
 
I'm using winpython, and installed pyqtgraph to the folder.
 
Here is my cx_freeze script:
 
import sys

from cx_Freeze import setup, Executable


# Dependencies are automatically detected, but it might need fine tuning.

build_exe_options = {"excludes": ["tkinter","cvxopt","PySide","matplotlib"],

"packages":["PyQt4.QtGui","PyQt4.QtCore","atexit",'pyqtgraph'],"include_msvcr":True,

'compressed':True,'copy_dependent_files':True,'create_shared_zip':True,

'include_in_shared_zip':True,'optimize':2}


# GUI applications require a different base on Windows (the default is for a

# console application).

base = None

if sys.platform == "win32":

base = "Win32GUI"


I included the error in the attachment.

 

Thank  you very much for your help.

 

 


pyqtgrapherror.PNG

Luke Campagnola

unread,
May 30, 2014, 12:15:31 AM5/30/14
to pyqt...@googlegroups.com
On Wed, May 21, 2014 at 5:37 PM, Jerry Prawiharjo <j.praw...@gmail.com> wrote:
Hi all,
 
I'm having difficulty now trying to bundle my application with cx_freeze.

Hi Jerry,
The error message seems to be related to the dynamic imports used in version 0.9.8. The latest develop branch on github has done away with dynamic imports, so perhaps you could try that instead?

Luke

Jerry Prawiharjo

unread,
May 30, 2014, 12:42:04 PM5/30/14
to pyqt...@googlegroups.com
Hi Luke,
 
Thank you for your response. I'm trying the develop version on GitHub now. At the moment, the cx_freeze spits out error such as :
 
Traceback (most recent call last):
  File "C:\WinPython\python-2.7.6\Scripts\cxfreeze", line 5, in <module>
    main()
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\main.py", line 188, in main
    freezer.Freeze()
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\freezer.py", line 577, in Freeze
    self._FreezeExecutable(executable)
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\freezer.py", line 161, in _FreezeExecutable
    scriptModule = finder.IncludeFile(exe.script, exe.moduleName)
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\finder.py", line 558, in IncludeFile
    deferredImports)
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\finder.py", line 395, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\finder.py", line 494, in _ScanCode
    module, relativeImportIndex)
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\finder.py", line 264, in _ImportModule
    deferredImports, namespace = namespace)
  File "C:\WinPython\python-2.7.6\lib\site-packages\cx_Freeze\finder.py", line 338, in _InternalImportModule
    parentModule, namespace)
 
It seems that it still cannot find some dependencies from pyqtgraph. I'll try around with path include in cx_freeze if I can solve this issue.
 

Jerry Prawiharjo

unread,
Jun 4, 2014, 8:51:18 PM6/4/14
to pyqt...@googlegroups.com
Hi Luke,
 
It's now working, so I can bundle pyqtgraph using cx_freeze.
 
Thanks for your help.

Luke Campagnola

unread,
Jun 6, 2014, 12:39:28 PM6/6/14
to pyqt...@googlegroups.com
On Wed, Jun 4, 2014 at 6:51 PM, Jerry Prawiharjo <j.praw...@gmail.com> wrote:
 
It's now working, so I can bundle pyqtgraph using cx_freeze.

Great news, Jerry!
Would you be willing to share your insights with us, or perhaps write up a simple example using cx_freeze that highlights the solutions you came up with?


Luke

Jerry Prawiharjo

unread,
Jun 6, 2014, 2:30:32 PM6/6/14
to pyqt...@googlegroups.com
Hi Luke,
 
I used the github's development version, and here is my cx_freeze script:
I basically get the py2exe script example from GitHub folder, and modified it for cx_freeze


includes = ['PyQt4.QtCore', 'PyQt4.QtGui', 'sip', 'pyqtgraph.graphicsItems','numpy',"atexit"]

excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',"cvxopt",

'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl','tables',

'Tkconstants', 'Tkinter', 'zmq','PySide','pysideuic','scipy','matplotlib']

 

if sys.version[0] == '2':

# causes syntax error on py2

excludes.append('PyQt4.uic.port_v3')


base = None

if sys.platform == "win32":

base = "Win32GUI"


build_exe_options = {"excludes": excludes,

"includes":includes,"include_msvcr":True,

'compressed':True,'copy_dependent_files':True,'create_shared_zip':True,

'include_in_shared_zip':True,'optimize':2}


setup( name = "Test Software",

version = "0.1",

description = "uITLA test software",

options = {"build_exe": build_exe_options},

executables = [Executable("uITLATCscanQ.py", base=base)])


Luke Campagnola

unread,
Jun 6, 2014, 5:30:43 PM6/6/14
to pyqt...@googlegroups.com
On Fri, Jun 6, 2014 at 12:30 PM, Jerry Prawiharjo <j.praw...@gmail.com> wrote:
Hi Luke,
 
I used the github's development version, and here is my cx_freeze script:
I basically get the py2exe script example from GitHub folder, and modified it for cx_freeze

Thanks! I'll add this to the examples.

Reply all
Reply to author
Forward
0 new messages