1

我想将我的 python.exe 用于在我的计算机上编译和运行我的程序的所有 python 库和依赖项包含到由 py2exe 生成的 exe 中,因为py2exe **.exe* 生成的仍然返回错误和中止,

谢谢

这里是我在我的程序中使用的库:

from Tkinter import *  # POUR L'interface graphique
import tkFileDialog  # POUR l'ouverture d'
import csv
import ttk
import Tix as tix
import re  # regular exprun fichier
import tkMessageBox  # POUR un messageboxe pour quitter le programme
import py2exe, sys, os
import numpy as np
from threading import Thread
import datetime as dt
import pygal
from bokeh.plotting import figure, output_file, show
from datetime import datetime as time
import matplotlib.pyplot as plt
from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from matplotlib import cm
from matplotlib.dates import date2num
from matplotlib.gridspec import GridSpec
import matplotlib.dates as mdates

这里是我的 setup.exe 脚本:

import sys
import os
import glob
import os.path

from distutils.core import setup
import py2exe
sys.setrecursionlimit(5000)

sys.argv.append('py2exe')
"""
setup(
    options = {'py2exe': { 'compressed': True}},
    windows = [{'script': "D:\Users\u156726\PycharmProjects\SFR_APP\SFR_APP_BIG_DATA.py"}],
    zipfile = None,
)
"""
import matplotlib
import glob

setup(console=['D:\Users\u156726\PycharmProjects\SFR_APP\SFR_APP.py'],options={
               'py2exe': {
                          'packages' :  ['matplotlib', 'pytz'],

                          }
                },
4

1 回答 1

2

py2exe 提供“选项”参数来定义要包含或排除的包列表。当缺少包时,您可以强制 py2exe 将这些包捆绑到 exe 中。

查看文档以获取有关所有选项的更多信息。

includes = ['matplotlib', 'numpy', 'Tkinter', 'tcl', 'Tkconstants', ... ]
excludes = ['_gtkagg', '_tkagg', 'curses', 'pywin.debugger', 'pywin.debugger.dbgcon', 'pywin.dialogs' ]
packages = []
dll_excludes = []

setup(
    options = {"py2exe": {"compressed": 0,
                          "optimize": 0,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          "bundle_files": 1,
                          "dist_dir": ".",
                          "xref": False,
                          "skip_archive": False,
                          "ascii": False,
                          "custom_boot_script": '',
                         }
              },
    console=...,
)
于 2017-05-12T15:01:02.283 回答