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 583503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:48:00+00:00 2026-05-13T14:48:00+00:00

I’ve been trying to pack my app with py2exe. The application works fine but

  • 0

I’ve been trying to pack my app with py2exe. The application works fine but it keeps failing to find/use pywinauto. I been googling but I get nothing, I’m now I’m totally lost…

Here’s the packing script:

from distutils.core import setup

setup(
  windows = ["mainForm.py"],
  data_files=[
      ('', ['mainForm.ui']),
      ('', ['osk.sqlite'])
  ],
  options = {
              "py2exe":{
                        "optimize": 2,
                        "includes": [
                          'sip', 'pyttsx.drivers.sapi5', 'win32com', 'xml.etree.ElementTree', 'sqlite3',
                          'pywinauto', 'pywinauto.application', 'pywinauto.controls', 'pywinauto.tests', 'SendKeys'
                            ],
                          "typelibs": [('{C866CA3A-32F7-11D2-9602-00C04F8EE628}', 0, 5, 0)]
                         }
              }
    )

And here’s the ouput when running the exe

Traceback (most recent call last):
  File "mainForm.py", line 129, in changeState
  File "mainForm.py", line 230, in setWriteMode
  File "mainForm.py", line 105, in FillApps
  File "WindowHandler.pyo", line 26, in getWindowList
NameError: global name 'pywinauto' is not defined

I hope anyone could point me into the right direct.

Thanks in advance

  • 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-13T14:48:01+00:00Added an answer on May 13, 2026 at 2:48 pm

    From my experience, py2exe handles imports in a weird way. Sometimes it has trouble finding linked-imports (like you import WindowHandler, which imports pywinauto).

    I would start with this in mainForm.py:

    import sys
    import WordOps 
    import Voice 
    import WindowHandler
    from PyQt import QtCore, QtGui, uic
    

    And in setup.py, start with this:

    options={'py2exe':{
                        'includes': ['sip'],
                        'bundle_files': 1
                      }
            }
    

    Make sure your program works before compiling to an exe, then try running setup.py.
    When you start getting errors when running setup.py (like the one you posted), add more imports to mainForm.py. So for that error, your new header will look like:

    import sys
    import WordOps 
    import Voice 
    import WindowHandler
    from PyQt import QtCore, QtGui, uic
    # imports for py2exe
    import pywinauto
    

    It will not break your code because it will just be an “unused” import.
    Keep doing that until setup.py works.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from

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.