The data_files allows you to include one (or more) series of files that you are going to need to run your executable. For example, to run a GUI executable, I use data_files to create a folder in my dist directory called "images" and copy my list of image files over.

The data_files takes a tuple 1) the location to store the data and 2) the location to copy the data from

Example:

from distutils.core import setup
import py2exe

Mydata_files = [('images', ['c:/path/to/image/image.png'])]

setup(
console=['trypyglet.py.py']
data_files = Mydata_files
options={
"py2exe":{
"unbuffered": True,
"optimize": 2,
"excludes": ["email"]
}
}
)

More often you'll have a directory of image files, and you can use some code to push the directory into a list:

Example:

import os
from distutils.core import setup
import py2exe

Mydata_files = []
for files in os.listdir('C:\path\to\image\directory\'):
f1 = 'C:\path\to\image\directory\' + files
if os.path.isfile(f1): # skip directories
f2 = 'images', [f1]
Mydata_files.append(f2)

setup(
console=['trypyglet.py.py']
data_files = Mydata_files
options={
"py2exe":{
"unbuffered": True,
"optimize": 2,
"excludes": ["email"]
}
}
)