user1454024
user1454024

Reputation: 45

Using py2exe, how to create an executable usng python and tkinter?

I'm trying to turn a program that I've written in Python 2.7 (using tkinter for the GUI) into a standalone executable using py2exe. I've written the following script in a file called setup.py:

from distutils.core import setup
import py2exe
setup(data_files=['C:\Python27\tcl\tcl8.5\init.tcl'] , windows = ["Brand_Counter.py"])

When I run this, the command prompt opens for a second, then nothing happens. As far as I can tell, according to the documentation my code should create a subdirectory "dist" which will contain my executable, but this isn't happening. Does anybody see anything wrong with my code?

Upvotes: 1

Views: 3246

Answers (1)

Brian.D.Myers
Brian.D.Myers

Reputation: 2518

To do a build of a py2exe project, you should issue this command from the directory that contains your setup.py file:

python setup.py py2exe

Works well for me.

EDIT ---

In addition you're using the data_files parameter which takes a list of tuples. Your parameter should look something like this:

data_files=[('tclfiles', ['C:\Python27\tcl\tcl8.5\init.tcl'])]

Adjusted for wherever you want to place your init.tcl file. For more examples see this link: py2exe data_files

Upvotes: 1

Related Questions