-
Notifications
You must be signed in to change notification settings - Fork 92
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
pythoncom and pywintypes module import issue #170
Comments
Thanks for this detailed investigation. In general, support for Line 69 in d34da51
because I simply do not have the capacity to provide support for the whole Python ecosystem. That being said, you are more than welcome to submit a PR with patches for |
@albertosottile Thank you for your reply. The frozen exe with Although the extension of How to import |
DLL loading should be done automatically when you |
I'm looking for a way to import pywintypes_dll_mod = import_from_frozen("pywintypes38.dll", ...) |
I do not follow you, why would you want to load the DLL manually? The EDIT: by looking at the code you pasted above, you should inspect |
Following is the reason to import
__import_pywin32_system_module__("pywintypes", globals())
for look in sys.path:
# If the sys.path entry is a (presumably) .zip file, use the
# directory
if os.path.isfile(look):
look = os.path.dirname(look)
found = os.path.join(look, filename)
if os.path.isfile(found):
break
raise ImportError(
"Module '%s' isn't in frozen sys.path %s" % (modname, sys.path)
pywintypes.__import_pywin32_system_module__("pythoncom", globals())
# Load the DLL.
loader = importlib.machinery.ExtensionFileLoader(modname, found)
spec = importlib.machinery.ModuleSpec(name=modname, loader=loader, origin=found)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
|
Why do you think the hook is swallowing this exception? I cannot see an
In general, the code you pasted here: # Load the DLL.
loader = importlib.machinery.ExtensionFileLoader(modname, found)
spec = importlib.machinery.ModuleSpec(name=modname, loader=loader, origin=found)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod) should also work from "frozen exe in runtime". This works OOTB when To facilitate debugging, I would advise you to start with |
test environment
When import pywintypes, pythoncom, I have same problem with Inconsistent builds: ExtensionDLL copying order #149
AttributeError: module 'pywintypes' has no attribute '__import_pywin32_system_module__'
My Workaround
bundle_files
to2
data_files
as belowBut, I want to use with
bundle_files=0
.Is there any way to fix the
hook_pythoncom
andhook_pywintypes
?Below is the result of my analyze.
execution result of frozen
main.py
pythoncom38.dll
andpywintypes38.dll
cannot be found in sys.path, ImportError is raised at line 44 at 'import_pywin32_system_module' inpywintypes.py
py2exe.hooks.hook_pywintypes
and the remaining code in__import_pywin32_system_module__
is not executed.del py2exe.hooks.hook_pywintypes
inmain.py
data_files
indist_py2exe.py
pythoncom38.dll
andpywintypes38.dll
depend onpython38.dll
bundle_files
from0
to2
indist_py2exe.py
__import_pywin32_system_module__=True
dist_py2exe.py
sourcemain.py
sourceThe text was updated successfully, but these errors were encountered: