[python-win32] Next step trying to include extra/external file in py2exe output

Tim Roberts timr at probo.com
Tue May 24 22:54:24 CEST 2011


Jacob Kruger wrote:
> #error text from console window
>     raise ImportError, "No module named " + qname
> ImportError: No module named c:\temp\pythonScripts\mapDataFn
>
> Should I rather copy that file to somewhere else, and then just tell it to 
> do something like:
> "includes" : ["mapDataFn"]
>
> Also tried changing it to:
> "includes" : ["mapDataFn.py"]
>
> and, same issue/error.

Here's a trivial example.  When I run "python setup.py py2exe", it
creates dist\main.exe and dist\library.zip, and the zip contains
mapDataFn.pyc, among all the standard modules.

C:\Dev\xxx>type main.py
from mapDataFn import fnTakeItem

print fnTakeItem()

C:\Dev\xxx>type mapDataFn.py
def fnTakeItem():
    return 123

C:\Dev\xxx>type setup.py
from distutils.core import setup
import py2exe

options = {
    "bundle_files": 1,
    "ascii": 1, # to make a smaller executable, don't include the encodings
    "compressed": 1, # compress the library archive
    }

setup(
    # The first three parameters are not required, if at least a
    # 'version' is given, then a versioninfo resource is built from
    # them and added to the executables.
    version = "1.0.0",
    description = "Test",
    name = "MapTest",
    options = {'py2exe': options},

    # targets to build
    console = ["main.py"],
    )

C:\Dev\xxx>python setup.py py2exe
running py2exe
creating C:\Dev\xxx\build
creating C:\Dev\xxx\build\bdist.win32
creating C:\Dev\xxx\build\bdist.win32\winexe
creating C:\Dev\xxx\build\bdist.win32\winexe\collect-2.6
creating C:\Dev\xxx\build\bdist.win32\winexe\bundle-2.6
creating C:\Dev\xxx\build\bdist.win32\winexe\temp
creating C:\Dev\xxx\dist
*** searching for required modules ***
*** parsing results ***
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
byte-compiling C:\Dev\xxx\mapDataFn.py to mapDataFn.pyc
byte-compiling c:\apps\python26\lib\StringIO.py to StringIO.pyc

... lots of output deleted ...

C:\Dev\xxx>cd dist

C:\Dev\xxx\dist>main.exe
123

C:\Dev\xxx\dist>

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list