# Where is the documentation page which explains how imports modify the sys.path?

**URL:** <https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823>\
**Category:** Python Help\
**Created:** [July 10, 2024, 1:45pm UTC](https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823 "2024-07-10T13:45:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hypernova](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hypernova](https://discuss.python.org/u/hypernova)\
**Post date:** [July 10, 2024, 1:45pm UTC](https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823/1 "2024-07-10T13:45:07Z")

</div>

I’m sure somewhere there is a documentation page which explains how the `import` statement modifies the `sys.path` variable depending on the form of the import.

For example, packages and modules have slightly different rules.

This is also related to executing a module, or executing a module inside a package with `python3 -m`. The two forms also change how `sys.path` is initialized.

If someone knows where this page is and could help me find it I would greatly appreciate it.

Thanks

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [July 10, 2024, 2:00pm UTC](https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823/2 "2024-07-10T14:00:13Z")

</div>

The `import` statement does not modify `sys.path`, it just uses it.

The difference between the different methods to execute python is documented right by [`sys.path`](https://docs.python.org/3/library/sys.html#sys.path), but I agree that this information is a bit scattered. Most of your questions should be answered by [5. The import system — Python 3.12.4 documentation](https://docs.python.org/3/reference/import.html)

---

<div class="post-metadata">

**Author:** ![jamestwebber](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamestwebber/32/12799_2.png) [@jamestwebber](https://discuss.python.org/u/jamestwebber)\
**Post date:** [July 10, 2024, 2:08pm UTC](https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823/3 "2024-07-10T14:08:23Z")

</div>

> [@MegaIng](#):
>
> The `import` statement does not modify `sys.path`, it just uses it.

Of course, the only caveat being that whatever you `import` is going to be run. If _that module_ modifies the path, all bets are off.

If it seems like `sys.path` is being modified during imports, then I would be checking my dependencies in case somebody is doing something weird.

---

<div class="post-metadata">

**Author:** ![hypernova](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hypernova](https://discuss.python.org/u/hypernova)\
**Post date:** [July 10, 2024, 2:11pm UTC](https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823/4 "2024-07-10T14:11:51Z")

</div>

I’m sure somewhere I have seen a table which describes how certain attributes are changed such as ` __package__ `, ` __path__ `, ` __name__ ` etc.

does anyone recall this?

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [July 10, 2024, 2:18pm UTC](https://discuss.python.org/t/where-is-the-documentation-page-which-explains-how-imports-modify-the-sys-path/57823/5 "2024-07-10T14:18:31Z")

</div>

[5. The import system — Python 3.12.4 documentation](https://docs.python.org/3/reference/import.html#import-related-module-attributes) probably this one? But that ` __path__ ` is not really related to `sys.path`
