Hi Everyone

Has anybody succeeded in packaging an application using sklearn with py2exe?

A "simple application`` like:

import sklearn.decomposition.pca
pass

With the following setup script (generated with the help of GUI2exe):

 ======================================================== #
# File automagically generated by GUI2Exe version 0.5.3
# Copyright: (c) 2007-2012 Andrea Gavana
# ======================================================== #

# Let's start with some default (for me) imports...

from distutils.core import setup
from py2exe.build_exe import py2exe

import glob
import os
import zlib
import shutil

# Remove the build folder
shutil.rmtree("build", ignore_errors=True)


class Target(object):
    """ A simple class that holds information on our executable file. """
    def __init__(self, **kw):
        """ Default class constructor. Update as you need. """
        self.__dict__.update(kw)


# Ok, let's explain why I am doing that.
# Often, data_files, excludes and dll_excludes (but also resources)
# can be very long list of things, and this will clutter too much
# the setup call at the end of this file. So, I put all the big lists
# here and I wrap them using the textwrap module.

data_files = []

includes = ['scipy.sparse.csgraph._validation', 'sklearn.decomposition.pca']
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
            'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
                'tk84.dll']
icon_resources = []
bitmap_resources = []
other_resources = []


# This is a place where the user custom code may go. You can do almost
# whatever you want, even modify the data_files, includes and friends
# here as long as they have the same variable name that the setup call
# below is expecting.

# No custom code added


# Ok, now we are going to build our target class.
# I chose this building strategy as it works perfectly for me :-D

GUI2Exe_Target_1 = Target(
    # what to build
    script = "exe.py",
    icon_resources = icon_resources,
    bitmap_resources = bitmap_resources,
    other_resources = other_resources,
    dest_base = "exe",
    version = "0.1",
    company_name = "No Company",
    copyright = "No Copyrights",
    name = "Py2Exe Sample File",

    )

# No custom class for UPX compression or Inno Setup script

# That's serious now: we have all (or almost all) the options py2exe
# supports. I put them all even if some of them are usually defaulted
# and not used. Some of them I didn't even know about.

setup(

    # No UPX or Inno Setup

    data_files = data_files,

    options = {"py2exe": {"compressed": 2,
                          "optimize": 1,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          "bundle_files": 2,
                          "dist_dir": "dist",
                          "xref": False,
                          "skip_archive": False,
                          "ascii": False,
                          "custom_boot_script": '',
                         }
              },

    zipfile = None,
    console = [GUI2Exe_Target_1],
    windows = [],
    service = [],
    com_server = [],
    ctypes_com_server = []
    )


Will produce an exe that will crash with the the following messages:


C:\ProFDDWork\Subversionned\test\dist>exe.exe
Traceback (most recent call last):
  File "exe.py", line 1, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "sklearn\decomposition\__init__.pyo", line 10, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "sklearn\decomposition\sparse_pca.pyo", line 8, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "sklearn\linear_model\__init__.pyo", line 20, in <module>
  File "zipextimporter.pyo", line 98, in load_module
  File "weight_vector.pxd", line 14, in init sklearn.linear_model.sgd_fast 
(sklearn\linear_model\sgd_fast.c:10823)
ImportError: No module named weight_vector


Anybody has a clue as to what is going on?

Sorry for the long post :-(

Dr Alain Legault

scientifique sénior | senior scientist

Groupe Optimisation des Procédés Industriels | Industrial Systems Optimization 
Group

CanmetÉNERGIE  | CanmetENERGY
Ressources naturelles Canada | Natural Resources Canada
1615 Lionel-Boulet, C.P. 4800, Varennes, Qc J3X 1S6



[email protected]<mailto:[email protected]>
Téléphone | Telephone +1-450-652-7031

Télécopieur | Facsimile +1-450-652-5918



Gouvernement du Canada | Government of Canada

www.canmetenergie.rncan.gc.ca<http://www.canmetenergie.rncan.gc.ca/> | 
www.canmetenergy.nrcan.gc.ca<http://www.canmetenergy.nrcan.gc.ca/>



------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to