[issue46806] Overlapping PYTHONPATH may cause import already imported module
Eric Snow
report at bugs.python.org
Tue Feb 22 11:23:46 EST 2022
Eric Snow <ericsnowcurrently at gmail.com> added the comment:
When you run a Python script, the directory the script is in is automatically added to the beginning of sys.path. This is the fundamental issue you've run into.
Basically, "src.common_object" is imported relative to the "src" that was imported relative to that automatically added sys.path entry. However, "common_object" is a distinct module imported relative to the sys.path entry you explicitly added.
In general, adding a package's directory to sys.path is a bad idea.
----------
nosy: +eric.snow
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46806>
_______________________________________
More information about the Python-bugs-list
mailing list