Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to create executable using pyinstaller for kivy application containing pywinauto #343

Open
GoelPri opened this issue Nov 4, 2021 · 1 comment
Labels
state:triage We're still figuring out how severe this issue is

Comments

@GoelPri
Copy link

GoelPri commented Nov 4, 2021

Hi guys,
I was creating an executable for kivy application. And it uses a python script that requires pywinauto. After building the exe using pyinistaller on the spec file, I was unable to access the exe. It is throwing an error with thread issue concerning comtypes of pywinauto.

I built this on Ananconda.

I got the following error down below.

Has anyone encountered the same? Please help , need to resolve this soon

  • Which hook/library isn't working?
    Pyinstaller is unable to create exe for python file with pywinauto reference.
  • Does the error get raised while building or when running?
    Error when running the exe

import pywinauto.application
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "pywinauto_init.py", line 87, in
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "pywinauto\sysinfo.py", line 44, in
File "", line 991, in _find_and_load
File "", line 975, in find_and_load_unlocked
File "", line 671, in load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "comtypes_init.py", line 160, in
File "comtypes_init.py", line 151, in CoInitializeEx
File "_ctypes/callproc.c", line 935, in GetResult
OSError: [WinError -2147417850] Cannot change thread mode after it is set

I want to run my kivy application as exe
A clear and concise description of what you expected to happen.

image

Desktop (please complete the following information):

  • OS: Windows
  • Python Version: 3.8.8
  • Version of pyinstaller-hooks-contrib: 2021.3
  • Version of PyInstaller - 4.6
@GoelPri GoelPri added the state:triage We're still figuring out how severe this issue is label Nov 4, 2021
@rokm
Copy link
Member

rokm commented Nov 4, 2021

This looks like a variant of pyinstaller/pyinstaller#6198, which is caused by win32com being imported before the other package that tries to set the thread mode (which in this case seems to be comtypes).

In PyInstaller-frozen application, win32com is automatically imported via the pkg_resources and win32com runtime hooks, so the work-around is to modify those runtime hooks to import the other package before they import pkg_resources and win32com, as per pyinstaller/pyinstaller#6198 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:triage We're still figuring out how severe this issue is
Projects
None yet
Development

No branches or pull requests

2 participants