mhammond / pywin32

Python for Windows (pywin32) Extensions
4.9k stars 783 forks source link

__import_pywin32_system_module_ function is not finding pywintypesXX.dll even if it exists #2298

Open Ilyeshaddad337 opened 1 week ago

Ilyeshaddad337 commented 1 week ago

Expected behavior and actual behavior

when I import the win32com.client module i get this error python DLL load failed: The specified module could not be found the line producing the error is : python \venv\lib\site-packages\win32\lib\pywintypes.py line 118 in __pywin32_system_module__ mod = importlib.util.module_from_spec(spec) when i print the spec variable that is defined just above that line i see that it contains the correct path to the dll: python ModuleSpec(name='pywintypes', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x0000020060A79208>, origin='C:\\Users\\ilyes\\Documents\\venv\\lib\\site-packages\\pywin32_system32\\pywintypes37.dll')

Steps to reproduce the problem

just import the win32com.client module

System information

Python version and distribution: python3.7 , windows

pywin32 version: pywin32==306 installed via pip

Windows Version: windows 10 22H2 19045.4412 installed on virtual machine

DLL locations: pythoncom37.dll pywintypes37.dll are found on venv\lib\site-packages\pywin32_system32\

mhammond commented 4 days ago

This probably means the dependencies for pywintypes37.dll can't be found - eg, maybe the MSVC redistributables. A "dependency" tool, such as https://www.dependencywalker.com/, might be able to shed more light here.