I have the following structure, parts of the code are forks from other people and parts written by me
parentfolder/
main.py
utils.py
fun1.py
/childfolder/
__init__.py
main_child.py
function.py
/utils/
__init__.py
foo.py
Now in the function.py
, I imported the utils
module in the parentfolder following Importing modules from parent folder
(I use an interative python console binded with vim so the __file__
solution does not work for me)
in my main_child.py
, i imported function
, as well fun1
in the parent folder, which import utils
in the parent folder
when i run main_child.py
, it complains
ImportError: cannot import name 'xxx' from 'utils' (parentfolder/childfolder/utils/__init__.py)
this error is caused in importing fun1
since fun1
import utils
in the parentfolder, but now it seems that it only search the filderfolder
any solutions?