gpt4 book ai didi

python - 无法运行py2exe

转载 作者:太空宇宙 更新时间:2023-11-04 03:52:38 25 4
gpt4 key购买 nike

我尝试了很多方法,但我做的大多数代码(例如打印“f”)都运行良好。我不确定为什么我的代码在 exe 中不起作用。以下是我得到的错误

from distutils.core import setup
import py2exe

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

enter image description here

错误我得到了 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

这是我使用的所有 LIB,是不是某些库不能很好地与 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

最佳答案

这是 py2exe 的一个已知问题,请参阅 http://www.py2exe.org/index.cgi/MatPlotLib

创建 bundle 时,py2exe 要求您指定需要的任何外部文件。

如果您正在寻找更自动化的东西,请查看 pyinstaller项目(许多常用库已经处理 - 不是魔术,而是因为作者和贡献者已经注意指定许多常用 python 库需要哪些外部文件)。

关于python - 无法运行py2exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20488556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com