My question is much the same as this already answered question(Missing tkinter attributes after converting to py2exe executable). But it relates to python 2.7, which uses Tkinter, instead of tkinter.
I am basically having the same issue running my executable after compiling.
Traceback (most recent call last):
File "main.py", line 5, in <module>
File "gui.pyc", line 5, in <module>
File "matplotlib\backends\backend_tkagg.pyc", line 7, in <module>
File "six.pyc", line 199, in load_module
File "six.pyc", line 113, in _resolve
File "six.pyc", line 80, in _import_module
ImportError: No module named FileDialog
But as I am using Tkinter with python 2.7 it means I can not do:
from tkinter import FileDialog
I have tried using
from tkFileDialog import askopenfilename
and
import tkFileDialog
but none have worked. Am I facing having to upgrade python to 3 just to be able to properly compile Tkinter? Or is there a workaround I'm missing?
This is my current setup.py
from distutils.core import setup
from glob import glob
import py2exe
import sys
import matplotlib
sys.path.append("C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\redist\\x86\\Microsoft.VC90.CRT")
data_files = [("Microsoft.VC90.CRT",
glob(r'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]
data_files.extend(matplotlib.get_py2exe_datafiles())
setup(
data_files=data_files,
windows=['main.py'],
packages=[''],
name='ZLA',
version='0.1 beta',
description='Troubleshooter.',
requires=['matplotlib', 'PIL', 'py2exe']
)
I have tried to specify tkFileDialog in options: includes: but still no luck :(
options={'py2exe': {'includes': ['Tkinter', 'tkFileDialog']}, }
UPDATE:
I found the answer after some investigating. You can actually just
import FileDialog
UPDATE2:
If you want to avoid the "unused import" feedback some debuggers and ide's give you, you can add the package FileDialog to the packages dictionary of py2exe in stead
options={'py2exe': {'packages': ['FileDialog']},}
Perhaps someone can help clarify why either is more appropriate?
Instead of using "includes" use "packages" and only specify the package, in this case 'Tkinter'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With