I ran into the same problem, but this is not caused by the absence of the init .py file. The reason is that the project has two identical name modules, so PyCharm does not know how to import. It is strange that PyCharm only reports runtime error.
My project files:
source root1 |-- moduleA |-- __init__.py |-- A.py source root2 |-- moduleA |-- __init__.py |-- B.py
Actually, source root1 is my code, and source root2 is my test code.
therefore, the solution is to change the name of the test module.
source root1 |-- moduleA |-- __init__.py |-- A.py source root2 |-- testmoduleA |-- __init__.py |-- B.py
Kris zhang
source share