File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 88
99try :
1010 import pywin32_system32
11- except ImportError : # Python ≥3.6: replace ImportError with ModuleNotFoundError
11+ except ImportError :
1212 pass
1313else :
1414 import os
1717 # https://docs.python.org/3/reference/import.html#path-attributes-on-modules
1818 for path in pywin32_system32 .__path__ :
1919 if os .path .isdir (path ):
20- os .add_dll_directory (path )
20+ try :
21+ # First try the preferred method
22+ os .add_dll_directory (path )
23+ except Exception :
24+ # If anything fails, try to modify PATH if it exists
25+ try :
26+ if "PATH" in os .environ :
27+ os .environ ["PATH" ] = path + os .pathsep + os .environ ["PATH" ]
28+ else :
29+ # If PATH doesn't exist, just create it
30+ os .environ ["PATH" ] = path
31+ except Exception :
32+ # Last resort - if nothing works, just pass silently
33+ pass
2134 break
You can’t perform that action at this time.
0 commit comments