Skip to content

Commit 34c29cf

Browse files
committed
Improve ModuleNotFoundError when -S is passed
1 parent 3a64844 commit 34c29cf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Lib/traceback.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,10 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
11061106
suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name)
11071107
if suggestion:
11081108
self._str += f". Did you mean: '{suggestion}'?"
1109+
elif exc_type and issubclass(exc_type, ModuleNotFoundError) and \
1110+
sys.flags.no_site:
1111+
self._str += ". Site initialization is disabled, did you forget to add the \
1112+
site-package directory to sys.path?"
11091113
elif exc_type and issubclass(exc_type, (NameError, AttributeError)) and \
11101114
getattr(exc_value, "name", None) is not None:
11111115
wrong_name = getattr(exc_value, "name", None)

0 commit comments

Comments
 (0)