I\'m trying to generate an .exe file from a python script that uses wxPython and Matplotlib and it looks like to be impossible.
The imports I\'m doing (related with Matp
Py2exe documentation explains the source of the problem and give solutions. It worked for me. (matplotlib version 1.1.0, Python 2.7)
http://www.py2exe.org/index.cgi/MatPlotLib
Since I have no privilege to comment or evaluate other answers, I have to write my own one. Kirk's answer was the most valuable help for me. PyInstaller might be a workaround (have not tested it) but is definitely not the technical solution to the problem !
from distutils.core import setup
import py2exe
from distutils.filelist import findall
import os
import matplotlib
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
matplotlibdata_files = []
for f in matplotlibdata:
dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
matplotlibdata_files.append((os.path.split(dirname)[0], [f]))
setup(
console=['test.py'],
options={
'py2exe': {
'includes': ["sip", "PyQt4.QtGui"],
'packages' : ['matplotlib', 'pytz'],
'excludes': ['_gtkagg', '_tkagg']
}
},
data_files=matplotlibdata_files
)