1

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

When I try this, I get a syntax error that says the following: File "<stdin>", line 1 python setup.py py2exe In the error message there is an arrow (^) below the "p" in the word "setup". Does this happen when you run it? Any suggestions would be hugely appreciated. Thanks!
No I don't get that. Are you sure you're in the same directory as your setup.py file? OTOH, I am only using the console parameter to setup. If you're sure you're in the right directory, can you edit your question to include the exact error message?
Never mind, I think I see the problem. data_files takes a list of tuples. Each tuple contains a location to store and a location to copy from. See this link for examples: Py2exe data_files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.