Problems with cx freeze when using matplotlib and figure.
New to Python and have a script that runs fine in the IDE and the cx freeze build is successful with no errors but when I go to run the exe output it does nothing with no errors (same from cmd prompt window). Narrowed the strange behavior down to the first call to matplotlib figure initialization (i.e. skip the matplotlib calls and it runs). Any suggestions?
plt.figure(figsize=(5,5), dpi=100)
or
fig = Figure(figsize=(5,5), dpi=100)
Either has same do nothing behavior.
Using python34, latest libs, latest cx freeze and windows 10. Not sure where to start debuging from here. Here is the setup.py
import cx_Freeze import sys import matplotlib
base = None
if sys.platform == 'win32': base = "Win32GUI"
packages = ["tkinter","matplotlib","matplotlib.pyplot"] excludes = [] includes = [matplotlib.get_data_path()]
You must be logged in to post. Please login or register an account.
Could you also post the graphing code and and required data? Best thing I can do is try to make it run myself.
-Harrison 9 years ago
You must be logged in to post. Please login or register an account.
Thanks for your response and time! Below is only a snippet of the script arrived from when I was divide and conquering to find what cx freeze was having troubles with. When I did output the build result to a file I saw two warnings but they are there even when the matplotlib stuff is not run or imported and the exe runs so I think they are not critical. Installed and imported pywind32 but did not make a differnce
*** WARNING *** unable to create version resource install pywin32 extensions first
Again thanks for any input and the great site. Until I feel more comfortable with Python (by going through the tutorials) it is still kind of a black box to me as is cx freeze.
import matplotlib matplotlib.use("TkAgg") from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure import tkinter as tk from tkinter import ttk from tkinter import messagebox import string import sys import time import datetime import pywin32_system32 from PyQt4 import QtGui, QtCore
You must be logged in to post. Please login or register an account.
Ah, you didn't tell me about the tk part. Yikes! I did convert a tkinter application that uses Matplotlib in the past, have you tried to emulate the code? Here's the link:
Any reason for PyQt in this code? Get rid of that for sure, and any other modules you are not using.
-Harrison 9 years ago
Last edited 9 years ago
You must be logged in to post. Please login or register an account.
Sorry! The tk part on its own seems to work but not when mixing with matplotlib. Your tutorial link is what I looked at before attempting a cx freeze build. I tried to run that code but got an error (see below, maybe that is a clue to my orginal problem?). The PyQt was there from the complete code where I think I'm using a calendar widgit and maybe a list widget. If I remove all the unused libs from the code I posted it still has the "do nothing" result. Just trying to start by getting past that them hopefully the other stuff will just work. Thanks again!
"C:UsersRobertVirtual Env3Scriptspython.exe" C:/Users/Robert/Documents/Excersizeapp/tkinterVid28.py C:/Users/Robert/Documents/Excersizeapp/tkinterVid28.py:177: SyntaxWarning: name 'topIndicator' is assigned to before global declaration global topIndicator C:/Users/Robert/Documents/Excersizeapp/tkinterVid28.py:178: SyntaxWarning: name 'DatCounter' is assigned to before global declaration global DatCounter C:/Users/Robert/Documents/Excersizeapp/tkinterVid28.py:339: SyntaxWarning: name 'bottomIndicator' is assigned to before global declaration global bottomIndicator C:/Users/Robert/Documents/Excersizeapp/tkinterVid28.py:340: SyntaxWarning: name 'DatCounter' is assigned to before global declaration global DatCounter Traceback (most recent call last): File "C:/Users/Robert/Documents/Excersizeapp/tkinterVid28.py", line 20, in <module> import pandas as pd File "C:Python34libsite-packagespandas__init__.py", line 7, in <module> from pandas import hashtable, tslib, lib File "pandassrcnumpy.pxd", line 157, in init pandas.hashtable (pandashashtable.c:38262) ValueError: numpy.dtype has the wrong size, try recompiling
-roadjunky 9 years ago
You must be logged in to post. Please login or register an account.
Updated numpy lib and your example script runs (with syntax warnings). cx freeze build completes but when trying to run the exe output it does the "do nothing" same as my code.
-roadjunky 9 years ago
You must be logged in to post. Please login or register an account.
Should have spelled out I'm using cx_Freeze-4.3.4-cp34-none-win_amd64.whl matplotlib-1.5.0-cp34-none-win_amd64.whl numpy-1.10.4+mkl-cp34-none-win_amd64.whl
Any known issue with this combination?
-roadjunky 9 years ago
You must be logged in to post. Please login or register an account.
Not that I know of. I'll tinker a bit with it to see if I can figure it out when I get a chance.
-Harrison 9 years ago
You must be logged in to post. Please login or register an account.
Thanks, it is driving me a bit batty. Maybe it is a windows environment issue? Just surprised an exception is not thrown.
-roadjunky 9 years ago
You must be logged in to post. Please login or register an account.
Moved on to using C++ instead of Python. Trying to use Python scripting for a windows executable was a mistake. Works in some cases but not always. At least I learned a few things about Python in the process.
-roadjunky 9 years ago
You must be logged in to post. Please login or register an account.