4 ms·
The module search path (sys.path) is the thing you need to know about. With `python -m part2.week2`, by default `.` is added at the start. With `python part2/
by js2 2y ago
The module search path (sys.path) is the thing you need to know about.
With `python -m part2.week2`, by default `.` is added at the start.
With `python part2/week2.py`, `part2` (the script directory) is added at the start (instead of `.`).
So in the former case, `week2.py` is able to do something like `from part2 import ...` but not in the latter case.
But this should work `PYTHONPATH=. python part2/week2.py`.
https://docs.python.org/3/tutorial/modules.html#the-module-search-path https://docs.python.org/3/tutorial/modules.html#the-module-s...
https://docs.python.org/3/library/sys_path_init.html#sys-path-init https://docs.python.org/3/library/sys_path_init.html#sys-pat...