Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:30:20+00:00 2026-05-28T21:30:20+00:00

I’ve used py2exe several times in the past to create *.exe files for my

  • 0

I’ve used py2exe several times in the past to create *.exe files for my python programs. However, I’m getting an error this time. I think I know what the issue is, but I don’t know how to resolve it.

I have a handful of wx.Panels in a subfolder and it could be a variable amount, so I import them via a function that finds the *.py files in the folder and calls the function below to actually import each panel.

In normal python, this works well. However, py2exe leaves these files out. I assume that because they are not explicitly imported, py2exe doesn’t believe they are needed. Is there a solution to this? Some option in py2exe that I’m unaware of?

Thanks!

# module = Module to be imported (string)
# folder = Folder containing the module (string)
def import_module(module, folder=None):
   if folder is None:
      return __import__(module)
   return getattr(__import__('%s.%s' % (folder.replace(os.path.sep, '.'),
      module)), module)


...within some other function...
modules = [import_module(os.path.basename(os.path.splitext(filename)[0]), 'Panels') for filename in glob.glob('Panels//*.py')]

EDIT

I’m adding a sample setup.py script I’ve used. But I’ve used probably 20 different variations and several completely different scripts (what I could find on the internet). Note that one requirement is that it is completely self-contained in one executable file.

from distutils.core import setup
import py2exe

import wxversion
wxversion.select("2.8.12.1")
import wx
import wx.lib.pubsub

includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
            'Tkconstants', 'Tkinter']
packages = ['wx.lib.pubsub']
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
                'tk84.dll']

import glob
my_data_files = [('Panels', glob.glob('Panels/*.py'))]

setup(
    options = {"py2exe": {"compressed": 2,
                          "optimize": 2,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          "bundle_files": 2,
                          "dist_dir": "dist",
                          "xref": False,
                          "skip_archive": False,
                          "ascii": False,
                          "custom_boot_script": '',
                         }
              },
    zipfile = None,
    #data_files = my_data_files,
    windows=['Main.py']
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:30:20+00:00Added an answer on May 28, 2026 at 9:30 pm

    I believe I’ve found the solution for my issue. In my setup.py file, I replaced the ‘includes = []’ line with:

    includes = ['Panels.%s' % os.path.basename(os.path.splitext(filename)[0]) for
            filename in glob.glob('Panels//*.py')]
    

    In my code where I use the ‘import_module’ function, it used to use that glob to import the modules within the Panels directory. Instead, I’ve hard-coded a list of modules to include.

    This isn’t the exact solution I wanted (I don’t want to hard-code that list of panels), but it does seem to work. Unless I discover anything better, this is what I’ll continue to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.