You are getting that error because of the circular dependency of modules in your code.
When python tries to initialize your parent
module it sees the import child
statement, which leads the interpreter to the child
module, (Notice that parent
module is not initialized yet) now in the child module import parent
line is encountered, but since the parent module is not initialized yet, the interpreter will fail with the error that it cannot find the parent
module.
Ideally, you should fix the circular imports to solve this problem, But it can be overcome moving the import to a later stage instead of adding it at the top of the file. (For example: you can add the import statement in a method where you will be actually using the child module.) but it is not recommended to do this.