I am building a GUI that can take .txt or .xlsx files as input, performs some operations on them and returns the results as plots. I am using Python 3.4 and Tkinter 8.5 for the GUI.
It has a drop-down list for selecting the file type and a button for opening a dialog box to select the file. It then saves the contents of the file to a different file in the same directory. It also has a button to quit the program and a text box and a label which I was just playing with and do not serve any purpose.
The GUI works when I run the datagui.py
file. However I also want to make a cross-platform file that will not need Python to run it. I was using cx_freeze for this purpose to make an exe and wrote the following setup.py file to build it (available on the cx_Freeze website too):
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "datagui",
version = "0.1",
description = "My first GUI application",
executables = [Executable("datagui.py", base=base)])
When I try to run the datagui.exe
file located in the ...\build\exe.win-amd64-3.4
directory, I get the following error:
---------------------------
cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "datagui.py", line 3, in <module>
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\Users\Anish\Desktop\DR. DIXON\Data Analysis\python codes\dataselect.py", line 3, in <module>
from pylab import *
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\Anaconda3\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\Anaconda3\lib\site-packages\matplotlib\pylab.py", line 274, in <module>
from matplotlib.pyplot import *
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Anaconda3\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2224, in _find_and_load_unlocked
ImportError: No module named 'matplotlib.backends.backend_qt4agg'
What am I doing wrong here?
You might want to check out your matplotlib
configuration.
See this previous answer on matplotlib import
You need to indicate the type of back-end you want matplotlib to implement.
import matplotlib
matplotlib.use("Agg")