Using Numpy creates a tcl folder when using py2exe Using Numpy creates a tcl folder when using py2exe numpy numpy

Using Numpy creates a tcl folder when using py2exe


Modulefinder module which is used to determine dependencies gets "confused" and thinks you need Tkinter.

If you run following script...

from modulefinder import ModuleFinderfinder = ModuleFinder()finder.run_script('test.py')print finder.report()

...you will see found modules (shortened):

  Name                      File  ----                      ----m BaseHTTPServer            C:\Python27\lib\BaseHTTPServer.pym ConfigParser              C:\Python27\lib\ConfigParser.pym FixTk                     C:\Python27\lib\lib-tk\FixTk.pym SocketServer              C:\Python27\lib\SocketServer.pym StringIO                  C:\Python27\lib\StringIO.pym Tkconstants               C:\Python27\lib\lib-tk\Tkconstants.pym Tkinter                   C:\Python27\lib\lib-tk\Tkinter.pym UserDict                  C:\Python27\lib\UserDict.pym _LWPCookieJar             C:\Python27\lib\_LWPCookieJar.py...

So now we know that Tkinter is imported, but it is not very useful. The report does not show what is the offending module. However, it is enough information to exclude Tkinter by modifying py2exe script:

from distutils.core import setupimport py2exesetup(script_args = ['py2exe'],      windows=[{'script':'test.py'}],      options = {'py2exe': {'compressed':1,                            'bundle_files': 1,                            'excludes': ['Tkconstants', 'Tkinter']                            },                 },      zipfile = None)

Usually that is enough. If you are still curious what modules are the offending ones, ModuleFinder is not much helpful. But you can install modulegraph and its dependency altgraph. Then you can run the following script and redirect the output to a HTML file:

import modulegraph.modulegraphm = modulegraph.modulegraph.ModuleGraph()m.run_script("test.py")m.create_xref()

You will get dependency graph, where you will find that:

numpy -> numpy.lib -> numpy.lib.utils -> pydoc -> Tkinter