0

I was trying to compile my program using py2exe with the setup.py and all but whenever I try the console gives me this:

Traceback (most recent call last):
  File "setup.py", line 10, in <module>
zipfile = None)
  File "C:\Python34\lib\distutils\core.py", line 149, in setup
dist.run_commands()
  File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
  File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
  File "C:\Python34\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
  File "C:\Python34\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
  File "C:\Python34\lib\site-packages\py2exe\runtime.py", line 164, in analyze
mf.import_hook(modname)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 337, in 
_find_and_load
    raise ImportError(name)
ImportError: Tkinter

I run this via the console using python.exe setup.py py2exe

The setup.py looks something like so:

from distutils.core import setup import py2exe

setup(window=[{'script': 'filename.py'}], \
            options={"py2exe": {"includes": ["decimal", "Tkinter", \
            "tkFileDialog", "csv", "xml.dom.minidom", "os"], \
            'bundle_files': 3, 'compressed': False}}, \
            zipfile = None)


excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon",
             "pywin.dialogs", "pywin.dialogs.list", 
             "Tkconstants","Tkinter","tcl", "_imagingtk", "PIL._imagingtk", 
             "ImageTk", "PIL.ImageTk", "FixTk"
               ]

Please help, I do not know what I am doing.

Thank you

2 Answers 2

1

You are compiling with python 3. In python 3, the package is tkinter, not Tkinter

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

2 Comments

Thank you! However now it gives me: ImportError: tkFileDialog so umm what shall I do now?
@Egor.L: what should you do now? You need to do a bit more research about what has changed with tkinter between python 2 and 3.
0

I don't have enough reputation to add a comment, but the tkFiledialog error is similar to the Tkinter <--> tkinter error. In Python 3, you use import tkinter.filedialog as opposed to import tkFileDialog as in python 2.7

Comments

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.