root_package
|---main_package
| |--__init__.py
| |--main.py
|---write_to_file
| |--__init__.py
| |--write.py
|
|---__init__.py
I'm tryin to access a function that's in main.py from write.py like this:
write.py
from root_package.main_package.main import getProduct
and I get the following error: No module named 'root_package'
I know this is basic and most asked question, but I can't find the answer from other posts. I'm just not seeing what is wrong. Thanks
EDIT: I'm trying to run write.py script like this:
root_package\write_to_file\write.py python write.py
main.pyscript from? If fromroot_packagedirectory, tryfrom main_package.main import getProduct.write_to_filedirectory? Try usingfrom main_package.main import getProductand run it fromroot_packagewithpython write_to_file/write.py