Question

I tried a lot of way but most code i did for example print "f" worked well. i not sure why my code does not work in exe. Below is the error i get

from distutils.core import setup
import py2exe

setup(
    windows=[{'script': 'hello.py'}],
    options={
        'py2exe': 
        {
            'includes': ['lxml.etree', 'lxml._elementpath', 'gzip'],
        }
    }
)

enter image description here

Error i got hello.exe.log

Traceback (most recent call last):
File "hello.py", line 25, in <module>
File "matplotlib\__init__.pyc", line 765, in <module>
File "matplotlib\__init__.pyc", line 683, in rc_params
File "matplotlib\__init__.pyc", line 599, in matplotlib_fname
File "matplotlib\__init__.pyc", line 246, in wrapper
File "matplotlib\__init__.pyc", line 520, in _get_data_path_cached
File "matplotlib\__init__.pyc", line 516, in _get_data_path
RuntimeError: Could not find the matplotlib data files
Traceback (most recent call last):
File "hello.py", line 25, in <module>
File "matplotlib\__init__.pyc", line 765, in <module>
File "matplotlib\__init__.pyc", line 683, in rc_params
File "matplotlib\__init__.pyc", line 599, in matplotlib_fname
File "matplotlib\__init__.pyc", line 246, in wrapper
File "matplotlib\__init__.pyc", line 520, in _get_data_path_cached
File "matplotlib\__init__.pyc", line 516, in _get_data_path
RuntimeError: Could not find the matplotlib data files

This is all the LIB i used, is it some library doesnt work well with py2exe?

###### IMPORT STATEMENTS ######################################
import csv
import webbrowser
import heapq
from math import floor
import os
from os.path import basename, splitext
import re
from scipy import *
import string
import sys
from time import sleep
import time
import zipfile

from StringIO import StringIO
from Tkinter import *
import Tkinter as Tk
import lxml.etree as et
import matplotlib.cm as cm
from matplotlib.collections import PatchCollection
from matplotlib.patches import Rectangle, Circle, RegularPolygon
from matplotlib.pyplot import *
import matplotlib.pyplot as pl
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
import numpy as np
from pylab import *
import pylab as pl
import pylab as plot
from scipy.integrate import simps
import tkFileDialog
from tkFont import Font
import tkMessageBox
from scipy import interpolate
import pylab as py
import sys
Was it helpful?

Solution

This is a known problem with py2exe, see http://www.py2exe.org/index.cgi/MatPlotLib

When creating the bundle py2exe requires you to specify any external file that will be needed.

If you're looking for something more automatic take a look at pyinstaller project (where many common libraries are already handled - not by magic, but because authors and contributors already took care to specify which external files are needed for a lot of commonly used python libraries).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top