2

I have an application in which I added a module that plots data using vispy and scipy (for Delaunay). It works fine when I run within the Python (3.4 x64 on Windows) interpreter, but not when frozen using cx_freeze. It does not give me any error message, simply it does not run (quietly).

Here my cx_freeze script:

buildOptions = dict(packages = ['osgeo._gdal', 'scipy.sparse.csgraph._validation'])

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
    Executable('main.py', base=base, targetName = 'myApp.exe', icon='ico/myApp.ico')
    ]

setup(name='MyApp',
  version = '0.0.1',
  description = 'My fancy app',
  author = 'xxxx@xxxx.xxx',
  options = dict(build_exe = buildOptions),
  executables = executables)

I have to add 'scipy.sparse.csgraph._validation' to fix a previous missing inclusion as suggested here: scipy with py2exe and here

Looking for DLL issues, I have already attempted with Dependency Walker but without luck.

If I comment out the module with the vispy plot, everything works fine. Any hint?

Community
  • 1
  • 1
gmas80
  • 1,218
  • 1
  • 14
  • 44
  • Can somebody with enough reputation create a tag for `vispy`? I believe that will be quite popular in a near future.. – gmas80 Oct 25 '14 at 05:07
  • the tag was created! – Saullo G. P. Castro Oct 25 '14 at 09:34
  • 1
    Freezing code using scipy is a mess at present - there's [an issue open](https://bitbucket.org/anthony_tuininga/cx_freeze/issue/43/import-errors-when-using-cx_freeze-with) for it. I'm hoping to make things better for the next release of cx_Freeze, but finding the time to work on it is tricky. – Thomas K Oct 25 '14 at 20:13

2 Answers2

2

I have attempted to freeze just the module with the problem by adding a main with a QApplication that display the QWigdet with the vispy.app.canvas. This helped because I got a very useful backtrace error related to vispy.app.backends._pyside.

After explicitly adding this to my posted cx_freeze script, the frozen application works:

packages = ['osgeo._gdal', 'vispy.app.backends._pyside', 'scipy.sparse.csgraph._validation']

The difference that I found in the build directory is the presence of QtOpenGL4.dll and PySide.QtOpenGL.pyd. They were not there without the explicit package inclusion (my application was already using PySide).

gmas80
  • 1,218
  • 1
  • 14
  • 44
1

We've not thought about freezing apps with Vispy much yet. The pitfall that I'd expect matches with gmas80's answer; Vispy can use multiple backends, which means that these are dynamically loaded and cx_Freeze is unable to select the backend modules as a dependency. Depending on the backend that you need, you need to add some modules in vispy.backends to the list of includes.

Almar
  • 4,756
  • 2
  • 13
  • 9