👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I am running Python 2.5.
This is my folder tree:
ptdraft/
nib.py
simulations/
life/
life.py
(I also have __init__.py
in each folder, omitted here for readability)
How do I import the nib
module from inside the life
module? I am hoping it is possible to do without tinkering with sys.path.
Note: The main module being run is in the ptdraft
folder.
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Importing modules from parent folder, check other __main__ Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Importing modules from parent folder
- Deutsch Importing modules from parent folder
- Français Importing modules from parent folder
- Español Importing modules from parent folder
- Türk Importing modules from parent folder
- Русский Importing modules from parent folder
- Português Importing modules from parent folder
- Polski Importing modules from parent folder
- Nederlandse Importing modules from parent folder
- 中文 Importing modules from parent folder
- 한국어 Importing modules from parent folder
- 日本語 Importing modules from parent folder
- हिन्दी Importing modules from parent folder
Abu Dhabi | 2023-01-31
Simply put and clear. Thank you for sharing. Importing modules from parent folder and other issues with imp Python module was always my weak point 😁. I am just not quite sure it is the best method
Warsaw | 2023-01-31
I was preparing for my coding interview, thanks for clarifying this - Importing modules from parent folder in Python is not the simplest one. Will get back tomorrow with feedback
Texas | 2023-01-31
Maybe there are another answers? What Importing modules from parent folder exactly means?. Will use it in my bachelor thesis