Questions & Answers

I can't import sibling modules in my python package

My code grows longer and I am now working for making a package out of my modules.

I have a little question: when i try to import sibling packages it fails. from mypackage import module and import mypackage don't function where we use folders' names. but from module import method/class has always worked.


I want to import from a script in a sibling test folder.

I read all the posts concerning packaging modules but my problem seems to be less apparent. I didn't come across anybody facing it.

I don't know why questions already answered failed to solve my problem. Thank you for helping me.

2023-01-11 09:10:41
Without seeing the structure of the project, and without knowing from where you are running the relevant code (and whether you run this on the installed version of your package, or just the development version; yes, that can matter), we can't answer that.
2023-01-11 09:10:41
Perhaps enhance your question with a better explanation of your file structure. Your sibling folder is not a module by default. Perhaps try import test.bacaci.
Answers(0) :