File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 8
8
9
9
try :
10
10
import pywin32_system32
11
- except ImportError : # Python ≥3.6: replace ImportError with ModuleNotFoundError
11
+ except ImportError :
12
12
pass
13
13
else :
14
14
import os
17
17
# https://docs.python.org/3/reference/import.html#path-attributes-on-modules
18
18
for path in pywin32_system32 .__path__ :
19
19
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
21
34
break
You can’t perform that action at this time.
0 commit comments