我尝试了很多方法但是我做的大多数代码例如打印“f”运行良好。我不知道为什么我的代码在exe中不起作用。以下是我得到的错误
from distutils.core import setup
import py2exe
setup(
windows=[{'script': 'hello.py'}],
options={
'py2exe':
{
'includes': ['lxml.etree', 'lxml._elementpath', 'gzip'],
}
}
)
错误我收到了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
###### 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
答案 0 :(得分:2)
这是py2exe的已知问题,请参阅http://www.py2exe.org/index.cgi/MatPlotLib
创建包时,py2exe要求您指定所需的任何外部文件。
如果您正在寻找更自动的东西,请查看pyinstaller项目(其中已经处理了许多常用库 - 不是魔术,而是因为作者和贡献者已经注意指定需要哪些外部文件对于很多常用的python库)。