1

I want to include all python libraries and dependencies that my python.exe uses to compile and run my programm on my computer, into the exe Generated by py2exe, I want that because py2exe **.exe* generated is still returning errors and aborts,

Thank you

Here libraries that I used in my programm:

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

And here my setup.exe script:

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'],

                          }
                },
belkacem mekakleb
  • 584
  • 2
  • 7
  • 22

1 Answers1

2

py2exe offers 'options' parameter to define a list of packages to include or exclude. When there are packages missing you can force py2exe to bundle those packages into the exe.

Review to docs for more informations about all the options.

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=...,
)
Maurice Meyer
  • 17,279
  • 4
  • 30
  • 47
  • Thank you @Maurice, So I am using Windows64 and it causes problem with budle-files1 "error: bundle-files 1 not yet supported on win64" – belkacem mekakleb May 12 '17 at 15:37
  • Then dont bundle :) I was just copy-n-pasting what i am using since years, you may need to adjust to your needs. – Maurice Meyer May 12 '17 at 15:42
  • It still retruning errors like: File "matplotlib\__init__.pyc", line 1131, in File "matplotlib\__init__.pyc", line 965, in rc_params File "matplotlib\__init__.pyc", line 815, in matplotlib_fname File "matplotlib\__init__.pyc", line 320, in wrapper File "matplotlib\__init__.pyc", line 718, in _get_data_path_cached File "matplotlib\__init__.pyc", line 713, in _get_data_path RuntimeError: Could not find the matplotlib data files – belkacem mekakleb May 12 '17 at 16:01