Skip to content

Commit 787e2d3

Browse files
authored
Use module.__path__[0] instead of module.__file__ (#2769)
Fix #2751. If `__init__.py` does not exist, `module.__file__` is `None` (it is expected to give the path to `__init__.py`). In this case, `module.__path__[0]` will give the directory path. Signed-off-by: Jinzhe Zeng <[email protected]>
1 parent f97b4f2 commit 787e2d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

deepmd/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def dlopen_library(module: str, filename: str):
4848
except ModuleNotFoundError:
4949
pass
5050
else:
51-
libs = sorted(Path(m.__file__).parent.glob(filename))
51+
libs = sorted(Path(m.__path__[0]).glob(filename))
5252
# hope that there is only one version installed...
5353
if len(libs):
5454
ctypes.CDLL(str(libs[0].absolute()))

0 commit comments

Comments
 (0)